Skip to content

Commit

Permalink
Clear flag widget when there is no string after 'flags' in the text p…
Browse files Browse the repository at this point in the history
…rompt

Ensures the flag widget is cleared of all items if there is no string after 'flags' in the text prompt. This prevents any outdated or irrelevant items from being displayed, maintaining an accurate and clean state for the widget.
  • Loading branch information
healthonrails committed May 30, 2024
1 parent d240a72 commit ab721f6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions annolid/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,15 @@ def _grounding_sam(self):
return

# Check if the prompt starts with 'flags:' and contains flags separated by commas
if prompt_text.startswith('flags:') and ',' in prompt_text:
if prompt_text.startswith('flags:'):
flags = {k.strip(): False for k in prompt_text.replace(
'flags:', '').split(',')}
self.loadFlags(flags)
'flags:', '').split(',') if len(k.strip()) > 0}
if len(flags.keys()) > 0:
self.loadFlags(flags)
else:
# # If there is no string after 'flags'
# in the text prompt, clear the flag widget
self.flag_widget.clear()
else:
self.canvas.predictAiRectangle(prompt_text)

Expand Down Expand Up @@ -1186,6 +1191,13 @@ def predict_is_ready(self, messege):
self, "Prediction Ready",
"Predictions for the video frames have been generated!")

def loadFlags(self, flags):
for key, flag in flags.items():
item = QtWidgets.QListWidgetItem(key)
item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
item.setCheckState(Qt.Checked if flag else Qt.Unchecked)
self.flag_widget.addItem(item)

def saveLabels(self, filename):
lf = LabelFile()
has_zone_shapes = False
Expand Down

0 comments on commit ab721f6

Please sign in to comment.