\r
def execute_command(self, _class=None, method=None,\r
command=None, args=None):\r
+ if args == None:\r
+ args = {}\r
+ if ('property' in self._c\r
+ and self.gui.config['selected command'] == command):\r
+ arg_names = [arg.name for arg in command.arguments]\r
+ for name,value in self._c['property'].get_values().items():\r
+ if name in arg_names:\r
+ args[name] = value\r
+ print 'executing', command.name, args\r
self.inqueue.put(CommandMessage(command, args))\r
results = []\r
while True:\r
for argument in command.arguments:\r
if argument.name == 'help':\r
continue\r
- self._c['property'].append_property(prop_from_argument(\r
- argument, curves=[], playlists=[])) # TODO: lookup playlists/curves\r
+ p = prop_from_argument(\r
+ argument, curves=[], playlists=[]) # TODO: lookup playlists/curves\r
+ if p == None:\r
+ continue # property intentionally not handled (yet)\r
+ self._c['property'].append_property(p)\r
+\r
self.gui.config['selected command'] = command # TODO: push to engine\r
\r
\r
name = self._name_for_id[self._canonical_id(_id)]\r
if self._is_command(name):\r
command = self._commands[name]\r
- args = {} # TODO: generate args\r
- in_callback(self, command, args)\r
+ in_callback(self, command)\r
\r
\r
class CommandsPanel (Panel, wx.Panel):\r
'execute': wx.Button(self, label='Execute'),\r
}\r
sizer = wx.BoxSizer(wx.VERTICAL)\r
- sizer.Add(self._c['tree'], 1, wx.EXPAND)\r
sizer.Add(self._c['execute'], 0, wx.EXPAND)\r
+ sizer.Add(self._c['tree'], 1, wx.EXPAND)\r
+ # Put 'tree' second because its min size may be large enough\r
+ # to push the button out of view.\r
self.SetSizer(sizer)\r
sizer.Fit(self)\r
\r
def prop_from_argument(argument, curves=None, playlists=None):\r
"""Convert a :class:`~hooke.command.Argument` to a :class:`Property`.\r
"""\r
+ type = argument.type\r
+ if type in ['driver']: # intentionally not handled (yet)\r
+ return None\r
if argument.count != 1:\r
raise NotImplementedError(argument)\r
kwargs = {\r
'label':argument.name,\r
'default':argument.default,\r
- 'help':argument.help,\r
+ 'help':argument.help(),\r
}\r
- type = argument.type\r
+ # type consolidation\r
if type == 'file':\r
type = 'path'\r
- if argument.type in ['string', 'bool', 'int', 'float', 'path']:\r
+ # type handling\r
+ if type in ['string', 'bool', 'int', 'float', 'path']:\r
_class = globals()['%sProperty' % type.capitalize()]\r
return _class(**kwargs)\r
- elif argument.type in ['curve', 'playlist']:\r
- if argument.type == 'curve':\r
+ elif type in ['curve', 'playlist']:\r
+ if type == 'curve':\r
choices = curves # extract from a particular playlist?\r
else:\r
choices = playlists\r
string = self.GetCellValue(row=row, col=0)\r
return property.value_for_string(string)\r
\r
+ def get_values(self):\r
+ return dict([(p.label, self.get_property(p.label))\r
+ for p in self._properties])\r
+\r
def _property_by_label(self, label):\r
props = [(i,p) for i,p in enumerate(self._properties)\r
if p.label == label]\r