From cd2e156c22ff4fd511be1a91b8d4a873ac448f8a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 10 Aug 2010 10:59:24 -0400 Subject: [PATCH] Enable hackish support for Argument.count == -1 (by setting it to 3) --- hooke/ui/gui/__init__.py | 9 ++++++--- hooke/ui/gui/panel/propertyeditor.py | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/hooke/ui/gui/__init__.py b/hooke/ui/gui/__init__.py index f09e672..6d17a7c 100644 --- a/hooke/ui/gui/__init__.py +++ b/hooke/ui/gui/__init__.py @@ -330,11 +330,14 @@ 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)] self.log.debug('executing %s with %s' % (command.name, args)) self.inqueue.put(CommandMessage(command, args)) results = [] diff --git a/hooke/ui/gui/panel/propertyeditor.py b/hooke/ui/gui/panel/propertyeditor.py index 5cc4469..95233fc 100644 --- a/hooke/ui/gui/panel/propertyeditor.py +++ b/hooke/ui/gui/panel/propertyeditor.py @@ -43,8 +43,10 @@ def props_from_argument(argument, curves=None, playlists=None): type = argument.type if type in ['driver']: # intentionally not handled (yet) return None - if argument.count == -1: - raise NotImplementedError(argument) # TODO: maybe just set count to 1? + count = argument.count + if count == -1: + count = 3 # HACK: should allow unlimited entries (somehow...) + argument._display_count = count # suport HACK in execute_command() kwargs = { #'label':argument.name, 'default':argument.default, @@ -64,10 +66,10 @@ def props_from_argument(argument, curves=None, playlists=None): kwargs['choices'] = choices else: raise NotImplementedError(argument.type) - if argument.count == 1: + if count == 1: labels = [argument.name] else: - labels = ['%s %d' % (argument.name, i) for i in range(argument.count)] + labels = ['%s %d' % (argument.name, i) for i in range(count)] return [(label, _class(label=label, **kwargs)) for label in labels] -- 2.26.2