from . import menu as menu
from . import navbar as navbar
from . import panel as panel
-from .panel.propertyeditor import prop_from_argument, prop_from_setting
+from .panel.propertyeditor import props_from_argument, props_from_setting
from . import statusbar as statusbar
self._setup_perspectives()
self._bind_events()
+ self.execute_command(
+ command=self._command_by_name('load playlist'),
+ args={'input':'test/data/test'},#vclamp_picoforce/playlist'},
+ )
self.execute_command(
command=self._command_by_name('load playlist'),
args={'input':'test/data/vclamp_picoforce/playlist'},
args = {}
if ('property editor' 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 editor'].get_values().items():
- if name in arg_names:
- args[name] = value
+ arg = self._c['property editor']._argument_from_label.get(
+ name, None)
+ if arg == None:
+ continue
+ elif arg.count == 1:
+ args[arg.name] = value
+ continue
+ # deal with counted arguments
+ if arg.name not in args:
+ args[arg.name] = {}
+ 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:
+ keys = sorted(args[arg.name].keys())
+ assert keys == range(arg.count), keys
+ args[arg.name] = [args[arg.name][i]
+ for i in range(arg.count)]
self.log.debug('executing %s with %s' % (command.name, args))
self.inqueue.put(CommandMessage(command, args))
results = []
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:
if argument.name == 'help':
continue
else:
curves = results[0]
- p = prop_from_argument(
+ ret = props_from_argument(
argument, curves=curves, playlists=playlists)
- if p == None:
+ if ret == None:
continue # property intentionally not handled (yet)
- self._c['property editor'].append_property(p)
+ for label,p in ret:
+ self._c['property editor'].append_property(p)
+ self._c['property editor']._argument_from_label[label] = (
+ argument)
self.gui.config['selected command'] = command # TODO: push to engine
import wx.grid
from . import Panel
+from ....plugin import argument_to_setting
+from ....util.convert import ANALOGS
-def prop_from_argument(argument, curves=None, playlists=None):
- """Convert a :class:`~hooke.command.Argument` to a :class:`Property`.
+def props_from_argument(argument, curves=None, playlists=None):
+ """Convert a :class:`~hooke.command.Argument` to a list of
+ :class:`Property`\s.
"""
type = argument.type
if type in ['driver']: # intentionally not handled (yet)
return None
- if argument.count != 1:
- raise NotImplementedError(argument)
+ if argument.count == -1:
+ raise NotImplementedError(argument) # TODO: maybe just set count to 1?
kwargs = {
- 'label':argument.name,
+ #'label':argument.name,
'default':argument.default,
'help':argument.help(),
}
- # type consolidation
- if type == 'file':
- type = 'path'
+ type = ANALOGS.get(type, type) # type consolidation
# type handling
if type in ['string', 'bool', 'int', 'float', 'path']:
_class = globals()['%sProperty' % type.capitalize()]
- return _class(**kwargs)
elif type in ['curve', 'playlist']:
if type == 'curve':
choices = curves # extracted from the current playlist
else:
choices = playlists
- return ChoiceProperty(choices=choices, **kwargs)
- raise NotImplementedError(argument.type)
-
-def prop_from_setting(setting):
- """Convert a :class:`~hooke.config.Setting` to a :class:`Property`.
+ properties = []
+ _class = ChoiceProperty
+ kwargs['choices'] = choices
+ else:
+ raise NotImplementedError(argument.type)
+ labels = ['%s %d' % (argument.name, i) for i in range(argument.count)]
+ return [(label, _class(label=label, **kwargs)) for label in labels]
+
+
+def props_from_setting(setting):
+ """Convert a :class:`~hooke.config.Setting` to a list of
+ :class:`Property`\s.
"""
+ # TODO: move props_from_argument code here and use
+ # argument_to_setting there.
raise NotImplementedError()
"""Enable tooltips.
"""
x,y = self.CalcUnscrolledPosition(event.GetPosition())
- col,row = self.XYToCell(x, y)
+ row,col = self.XYToCell(x, y)
if col == -1 or row == -1:
msg = ''
else: