From 0b4e5b90c75d86e3d586048ae50c27d24a4182f2 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 29 Jul 2010 12:36:38 -0400 Subject: [PATCH] Added FloatProperty and ChoiceProperty. ChoiceProperty will be used for 'curve', 'playlist', and possibly 'driver'. We'll group the outstanding types following: PathProperty(): 5 file 2 path To be renamed: 1 glob --> string To be determined: 3 object 3 dict 1 function Handled by callbacks, to allow clicking on plots: 1 point --- hooke/ui/gui/panel/propertyeditor2.py | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/hooke/ui/gui/panel/propertyeditor2.py b/hooke/ui/gui/panel/propertyeditor2.py index 90eb32a..7af1175 100644 --- a/hooke/ui/gui/panel/propertyeditor2.py +++ b/hooke/ui/gui/panel/propertyeditor2.py @@ -126,6 +126,38 @@ class IntProperty (Property): return int(string) +class FloatProperty (Property): + def __init__(self, **kwargs): + assert 'type' not in kwargs, kwargs + if 'default' not in kwargs: + kwargs['default'] = 0.0 + super(FloatProperty, self).__init__(type='float', **kwargs) + + def get_editor(self): + return wx.grid.GridCellFloatEditor() + + def get_renderer(self): + return wx.grid.GridCellFloatRenderer() + + def value_for_string(self, string): + return float(string) + + +class ChoiceProperty (Property): + def __init__(self, choices, **kwargs): + assert 'type' not in kwargs, kwargs + if 'default' not in kwargs: + kwargs['default'] = choices[0] + super(ChoiceProperty, self).__init__(type='choice', **kwargs) + self._choices = choices + + def get_editor(self): + return wx.grid.GridCellChoiceEditor(choices=self._choices) + + def get_renderer(self): + return None + #return wx.grid.GridCellChoiceRenderer() + #class PyFilesProperty(wxpg.PyArrayStringProperty): # def __init__(self, label, name = wxpg.LABEL_AS_NAME, value=[]): # wxpg.PyArrayStringProperty.__init__(self, label, name, value) @@ -397,6 +429,17 @@ class PropertyPanel(Panel, wx.grid.Grid): default=5, help='help for my int', )) + self.append_property(FloatProperty( + label='my float', + default=3.14159, + help='help for my float', + )) + self.append_property(ChoiceProperty( + choices=['choice A', 'choice B', 'choice C'], + label='my choice', + default='choice B', + help='help for my choice', + )) def GetRowLabelValue(self, col=0): """Retrieve the label for a particular column. -- 2.26.2