from . import menu as menu\r
from . import navbar as navbar\r
from . import panel as panel\r
+from .panel.propertyeditor2 import prop_from_argument, prop_from_setting\r
from . import prettyformat as prettyformat\r
from . import statusbar as statusbar\r
\r
\r
class HookeFrame (wx.Frame):\r
- """The main Hooke-interface window.\r
-\r
- \r
+ """The main Hooke-interface window. \r
"""\r
def __init__(self, gui, commands, inqueue, outqueue, *args, **kwargs):\r
super(HookeFrame, self).__init__(*args, **kwargs)\r
# Command panel interface\r
\r
def select_command(self, _class, method, command):\r
- return\r
- self.select_plugin(plugin=command.plugin)\r
- plugin = self.GetItemText(selected_item)\r
- if plugin != 'core':\r
- doc_string = eval('plugins.' + plugin + '.' + plugin + 'Commands.__doc__')\r
- else:\r
- doc_string = 'The module "core" contains Hooke core functionality'\r
- if doc_string is not None:\r
- self.panelAssistant.ChangeValue(doc_string)\r
- else:\r
- self.panelAssistant.ChangeValue('')\r
- panel.propertyeditor.PropertyEditor.Initialize(self.panelProperties, properties)\r
- self.gui.config['selected command'] = command\r
+ #self.select_plugin(plugin=command.plugin)\r
+ if 'assistant' in self._c:\r
+ self._c['assitant'].ChangeValue(command.help)\r
+ self._c['property'].clear()\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
+ self.gui.config['selected command'] = command # TODO: push to engine\r
\r
\r
\r
from . import Panel\r
\r
\r
-def prop_from_setting(setting):\r
- """Convert a :class:`~hooke.config.Setting` to a :class:`Property`.\r
- """\r
- raise NotImplementedError()\r
-\r
-def prop_from_argument(argument):\r
+def prop_from_argument(argument, curves=None, playlists=None):\r
"""Convert a :class:`~hooke.command.Argument` to a :class:`Property`.\r
"""\r
+ if argument.count != 1:\r
+ raise NotImplementedError(argument)\r
+ kwargs = {\r
+ 'label':argument.name,\r
+ 'default':argument.default,\r
+ 'help':argument.help,\r
+ }\r
+ type = argument.type\r
+ if type == 'file':\r
+ type = 'path'\r
+ if argument.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
+ choices = curves # extract from a particular playlist?\r
+ else:\r
+ choices = playlists\r
+ return ChoiceProperty(choices=[c.name for c in choices], **kwargs)\r
+ raise NotImplementedError(argument.type)\r
+\r
+def prop_from_setting(setting):\r
+ """Convert a :class:`~hooke.config.Setting` to a :class:`Property`.\r
+ """ \r
raise NotImplementedError()\r
\r
\r
\r
def get_editor(self):\r
return wx.grid.GridCellBoolEditor()\r
- #return wx.grid.GridCellChoiceEditor(choices=['true', 'false'])\r
\r
def get_renderer(self):\r
return wx.grid.GridCellBoolRenderer()\r
\r
\r
class PropertyPanel(Panel, wx.grid.Grid):\r
+ """UI to view/set config values and command argsuments.\r
+ """\r
def __init__(self, callbacks=None, **kwargs):\r
super(PropertyPanel, self).__init__(\r
name='propertyeditor', callbacks=callbacks, **kwargs)\r
self._last_tooltip = None\r
self.GetGridWindow().Bind(wx.EVT_MOTION, self._on_mouse_over)\r
\r
- # add example properties for testing\r
- self.append_property(StringProperty(\r
- label='my string',\r
- default='hithere',\r
- help='help for my string',\r
- ))\r
- self.append_property(BoolProperty(\r
- label='my bool',\r
- default=True,\r
- help='help for my bool',\r
- ))\r
- self.append_property(IntProperty(\r
- label='my int',\r
- default=5,\r
- help='help for my int',\r
- ))\r
- self.append_property(FloatProperty(\r
- label='my float',\r
- default=3.14159,\r
- help='help for my float',\r
- ))\r
- self.append_property(ChoiceProperty(\r
- choices=['choice A', 'choice B', 'choice C'],\r
- label='my choice',\r
- default='choice B',\r
- help='help for my choice',\r
- ))\r
-\r
- def GetRowLabelValue(self, col=0):\r
- """Retrieve the label for a particular column.\r
-\r
- Overrides the default labels, since 'SetRowLabelValue' seems\r
- to be `ignored`_.\r
-\r
- .. _ignored:\r
- http://wiki.wxpython.org/wxPyGridTableBase#Column.2BAC8-Row_Labels\r
- """\r
- return self._column_labels[col]\r
-\r
def _on_mouse_over(self, event):\r
"""Enable tooltips.\r
"""\r
if col == -1 or row == -1:\r
msg = ''\r
else:\r
- msg = self._properties[row].help\r
+ msg = self._properties[row].help or ''\r
if msg != self._last_tooltip:\r
self._last_tooltip = msg\r
event.GetEventObject().SetToolTipString(msg)\r
- self._get_values() # for testing\r
\r
def append_property(self, property):\r
if len([p for p in self._properties if p.label == property.label]) > 0:\r
self.SetCellRenderer(row=row, col=0, renderer=r)\r
self.set_property(property.label, property.default)\r
\r
+ def remove_property(self, label):\r
+ row,property = self._property_by_label(label)\r
+ self._properties.pop(row)\r
+ self.DeleteRows(pos=row)\r
+\r
+ def clear(self):\r
+ while(len(self._properties) > 0):\r
+ self.remove_property(self._properties[-1].label)\r
+\r
def set_property(self, label, value):\r
row,property = self._property_by_label(label)\r
self.SetCellValue(row=row, col=0, s=property.string_for_value(value))\r
string = self.GetCellValue(row=row, col=0)\r
return property.value_for_string(string)\r
\r
- def remove_property(self, label):\r
- row,property = self._property_by_label(label)\r
- raise NotImplementedError()\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
assert len(props) == 1, props\r
row,property = props[0]\r
return (row, property)\r
-\r
- def _get_values(self): # for testing\r
- for property in self._properties:\r
- v = self.get_property(property.label)\r
- print property.label, property.type, type(v), v\r