Skip to content

Commit

Permalink
Allow None values in options
Browse files Browse the repository at this point in the history
  • Loading branch information
sevisal committed Oct 6, 2023
1 parent f7ac460 commit 7790280
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/vai_lab/Data/xml_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,14 +526,14 @@ def _add_options(self,
option_text = ("\n{}".format(
"\n".join([*options[key]])))
new_option.text = option_text
elif isinstance(options[key], (int, float, str)):
elif isinstance(options[key], (int, float, str)) or options[key] is None:
new_option = opt_elem.find(str("./" + key))
if new_option is None:
new_option = ET.SubElement(opt_elem, key)
text_lead = "\n" if "\n" not in str(options[key]) else ""
new_option.text = "{0} {1}".format(
text_lead, str(options[key]))
elif isinstance(options[key], (dict)):
elif isinstance(options[key], dict):
self._add_options(opt_elem, options[key])

def append_input_data(self,
Expand Down
7 changes: 2 additions & 5 deletions src/vai_lab/utils/plugins/pluginCanvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,9 +749,7 @@ def OnDoubleClick(self, event):
self.entry = tk.Entry(self.tree, justify='center')
if int(self.treecol[1:]) > 0:
value = self.tree.item(self.treerow)['values'][int(str(self.treecol[1:]))-1]
value = str(value) if str(value) not in ['default', 'Choose X or Y'] else ''
self.entry.insert(0, value)
# self.entry['selectbackground'] = '#123456'
self.entry['exportselection'] = False

self.entry.focus_force()
Expand Down Expand Up @@ -780,14 +778,13 @@ def on_changeOption(self, *args):
""" Executed when the optionmenu is selected and pressed enter.
Saves the value"""
if hasattr(self, 'dropDown'):
value = self.tree.item(self.treerow)['values'][int(str(self.treecol[1:]))-2]
tags = self.tree.item(self.treerow)["tags"]
val = self.tree.item(self.treerow)['values']
new_val = self.method_inputData['_'.join(tags[:-1])].get()
val[int(self.treecol[1:])-1] = new_val
self.tree.item(self.treerow, values=tuple([val[0], new_val]))
self.dropDown.destroy()
self.saved = False
self.saved = False

def on_return(self, event):
""" Executed when the entry is edited and pressed enter.
Expand Down Expand Up @@ -903,7 +900,7 @@ def updateSettings(self, tag, f, key, value = None):

value = self.str_to_bool(value)
if tag == 'req':
if value is not None or self.isNotClose(self.req_settings[f][key], value):
if self.isNotClose(self.req_settings[f][key], value):
self.req_settings[f][key] = value
else:
self.req_settings[f].pop(key, None)
Expand Down

0 comments on commit 7790280

Please sign in to comment.