From 638060453ad06f7aeb8ad2b267eedbd6499d843d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 29 Jul 2010 15:02:09 -0400 Subject: [PATCH] Can successfully run 'load playlist' from CommandsPanel --- hooke/ui/gui/__init__.py | 17 +++++++++++++++-- hooke/ui/gui/panel/commands.py | 7 ++++--- hooke/ui/gui/panel/propertyeditor2.py | 18 +++++++++++++----- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/hooke/ui/gui/__init__.py b/hooke/ui/gui/__init__.py index 85c73e7..48bf62d 100644 --- a/hooke/ui/gui/__init__.py +++ b/hooke/ui/gui/__init__.py @@ -265,6 +265,15 @@ class HookeFrame (wx.Frame): def execute_command(self, _class=None, method=None, command=None, args=None): + if args == None: + args = {} + if ('property' in self._c + and self.gui.config['selected command'] == command): + arg_names = [arg.name for arg in command.arguments] + for name,value in self._c['property'].get_values().items(): + if name in arg_names: + args[name] = value + print 'executing', command.name, args self.inqueue.put(CommandMessage(command, args)) results = [] while True: @@ -665,8 +674,12 @@ class HookeFrame (wx.Frame): for argument in command.arguments: if argument.name == 'help': continue - self._c['property'].append_property(prop_from_argument( - argument, curves=[], playlists=[])) # TODO: lookup playlists/curves + p = prop_from_argument( + argument, curves=[], playlists=[]) # TODO: lookup playlists/curves + if p == None: + continue # property intentionally not handled (yet) + self._c['property'].append_property(p) + self.gui.config['selected command'] = command # TODO: push to engine diff --git a/hooke/ui/gui/panel/commands.py b/hooke/ui/gui/panel/commands.py index b8bae8d..3dbf138 100644 --- a/hooke/ui/gui/panel/commands.py +++ b/hooke/ui/gui/panel/commands.py @@ -133,8 +133,7 @@ class Tree (wx.TreeCtrl): name = self._name_for_id[self._canonical_id(_id)] if self._is_command(name): command = self._commands[name] - args = {} # TODO: generate args - in_callback(self, command, args) + in_callback(self, command) class CommandsPanel (Panel, wx.Panel): @@ -157,8 +156,10 @@ class CommandsPanel (Panel, wx.Panel): 'execute': wx.Button(self, label='Execute'), } sizer = wx.BoxSizer(wx.VERTICAL) - sizer.Add(self._c['tree'], 1, wx.EXPAND) sizer.Add(self._c['execute'], 0, wx.EXPAND) + sizer.Add(self._c['tree'], 1, wx.EXPAND) + # Put 'tree' second because its min size may be large enough + # to push the button out of view. self.SetSizer(sizer) sizer.Fit(self) diff --git a/hooke/ui/gui/panel/propertyeditor2.py b/hooke/ui/gui/panel/propertyeditor2.py index 4efe182..0bf04a3 100644 --- a/hooke/ui/gui/panel/propertyeditor2.py +++ b/hooke/ui/gui/panel/propertyeditor2.py @@ -20,21 +20,25 @@ from . import Panel def prop_from_argument(argument, curves=None, playlists=None): """Convert a :class:`~hooke.command.Argument` to a :class:`Property`. """ + type = argument.type + if type in ['driver']: # intentionally not handled (yet) + return None if argument.count != 1: raise NotImplementedError(argument) kwargs = { 'label':argument.name, 'default':argument.default, - 'help':argument.help, + 'help':argument.help(), } - type = argument.type + # type consolidation if type == 'file': type = 'path' - if argument.type in ['string', 'bool', 'int', 'float', 'path']: + # type handling + if type in ['string', 'bool', 'int', 'float', 'path']: _class = globals()['%sProperty' % type.capitalize()] return _class(**kwargs) - elif argument.type in ['curve', 'playlist']: - if argument.type == 'curve': + elif type in ['curve', 'playlist']: + if type == 'curve': choices = curves # extract from a particular playlist? else: choices = playlists @@ -245,6 +249,10 @@ class PropertyPanel(Panel, wx.grid.Grid): string = self.GetCellValue(row=row, col=0) return property.value_for_string(string) + def get_values(self): + return dict([(p.label, self.get_property(p.label)) + for p in self._properties]) + def _property_by_label(self, label): props = [(i,p) for i,p in enumerate(self._properties) if p.label == label] -- 2.26.2