Collapse None entries for Argument.count == -1 in the GUI
[hooke.git] / hooke / ui / gui / __init__.py
index fecc90d312c8680546d438af29c9e57a2d15851b..1c646f4396cc82429da7eb82cc55a601902b18f8 100644 (file)
@@ -194,11 +194,6 @@ class HookeFrame (wx.Frame):
                     style=wx.WANTS_CHARS,
                     # WANTS_CHARS so the panel doesn't eat the Return key.
                     ), 'center'),
-#            ('assistant', wx.TextCtrl(
-#                    parent=self,
-#                    pos=wx.Point(0, 0),
-#                    size=wx.Size(150, 90),
-#                    style=wx.NO_BORDER|wx.TE_MULTILINE), 'right'),
             (panel.PANELS['plot'](
                     callbacks={
                         '_set_status_text': self._on_plot_status_text,
@@ -217,7 +212,6 @@ class HookeFrame (wx.Frame):
 #            ('results', panel.results.Results(self), 'bottom'),
             ]:
             self._add_panel(p, style)
-        #self._c['assistant'].SetEditable(False)
 
     def _add_panel(self, panel, style):
         self._c[panel.name] = panel
@@ -336,11 +330,20 @@ class HookeFrame (wx.Frame):
                 index = int(name[len(arg.name):])
                 args[arg.name][index] = value
             for arg in command.arguments:
-                if arg.count != 1 and arg.name in args:
+                count = arg.count
+                if hasattr(arg, '_display_count'):  # support HACK in props_from_argument()
+                    count = arg._display_count
+                if count != 1 and arg.name in args:
                     keys = sorted(args[arg.name].keys())
-                    assert keys == range(arg.count), keys
+                    assert keys == range(count), keys
                     args[arg.name] = [args[arg.name][i]
-                                      for i in range(arg.count)]
+                                      for i in range(count)]
+                if arg.count == -1:
+                    while (len(args[arg.name]) > 0
+                           and args[arg.name][-1] == None):
+                        args[arg.name].pop()
+                    if len(args[arg.name]) == 0:
+                        args[arg.name] = arg.default
         self.log.debug('executing %s with %s' % (command.name, args))
         self.inqueue.put(CommandMessage(command, args))
         results = []
@@ -674,8 +677,6 @@ class HookeFrame (wx.Frame):
 
     def select_command(self, _class, method, command):
         #self.select_plugin(plugin=command.plugin)
-        if 'assistant' in self._c:
-            self._c['assitant'].ChangeValue(command.help)
         self._c['property editor'].clear()
         self._c['property editor']._argument_from_label = {}
         for argument in command.arguments:
@@ -735,6 +736,7 @@ class HookeFrame (wx.Frame):
         pass
 
     def _on_delete_curve(self, _class, method, playlist, curve):
+        # TODO: execute_command 'remove curve from playlist'
         os.remove(curve.path)
 
     def _on_set_selected_playlist(self, _class, method, playlist):