return None\r
#return wx.grid.GridCellChoiceRenderer()\r
\r
-#class PyFilesProperty(wxpg.PyArrayStringProperty):\r
-# def __init__(self, label, name = wxpg.LABEL_AS_NAME, value=[]):\r
-# wxpg.PyArrayStringProperty.__init__(self, label, name, value)\r
-# self.SetValue(value)\r
-#\r
-# def OnSetValue(self, v):\r
-# self.value = v\r
-# self.display = ', '.join(self.value)\r
-#\r
-# def GetValueAsString(self, argFlags):\r
-# return self.display\r
-#\r
-# def PyStringToValue(self, s, flags):\r
-# return [a.strip() for a in s.split(',')]\r
-#\r
-# def OnEvent(self, propgrid, ctrl, event):\r
-# if event.GetEventType() == wx.wxEVT_COMMAND_BUTTON_CLICKED:\r
-# # Show dialog to select a string, call DoSetValue and\r
-# # return True, if value changed.\r
-# return True\r
-#\r
-# return False\r
-#\r
-#\r
-#class PyObjectPropertyValue:\r
-# """\\r
-# Value type of our sample PyObjectProperty. We keep a simple dash-delimited\r
-# list of string given as argument to constructor.\r
-# """\r
-# def __init__(self, s=None):\r
-# try:\r
-# self.ls = [a.strip() for a in s.split('-')]\r
-# except:\r
-# self.ls = []\r
-#\r
-# def __repr__(self):\r
-# return ' - '.join(self.ls)\r
-#\r
-#\r
-#class PyObjectProperty(wxpg.PyProperty):\r
-# """\\r
-# Another simple example. This time our value is a PyObject (NOTE: we can't\r
-# return an arbitrary python object in DoGetValue. It cannot be a simple\r
-# type such as int, bool, double, or string, nor an array or wxObject based.\r
-# Dictionary, None, or any user-specified Python object is allowed).\r
-# """\r
-# def __init__(self, label, name = wxpg.LABEL_AS_NAME, value=None):\r
-# wxpg.PyProperty.__init__(self, label, name)\r
-# self.SetValue(value)\r
-#\r
-# def GetClassName(self):\r
-# return self.__class__.__name__\r
-#\r
-# def GetEditor(self):\r
-# return "TextCtrl"\r
-#\r
-# def GetValueAsString(self, flags):\r
-# return repr(self.GetValue())\r
-#\r
-# def PyStringToValue(self, s, flags):\r
-# return PyObjectPropertyValue(s)\r
-#\r
-#\r
-#class ShapeProperty(wxpg.PyEnumProperty):\r
-# """\\r
-# Demonstrates use of OnCustomPaint method.\r
-# """\r
-# def __init__(self, label, name = wxpg.LABEL_AS_NAME, value=-1):\r
-# wxpg.PyEnumProperty.__init__(self, label, name, ['Line','Circle','Rectangle'], [0,1,2], value)\r
-#\r
-# def OnMeasureImage(self, index):\r
-# return wxpg.DEFAULT_IMAGE_SIZE\r
-#\r
-# def OnCustomPaint(self, dc, rect, paint_data):\r
-# """\\r
-# paint_data.m_choiceItem is -1 if we are painting the control,\r
-# in which case we need to get the drawn item using DoGetValue.\r
-# """\r
-# item = paint_data.m_choiceItem\r
-# if item == -1:\r
-# item = self.DoGetValue()\r
-#\r
-# dc.SetPen(wx.Pen(wx.BLACK))\r
-# dc.SetBrush(wx.Brush(wx.BLACK))\r
-#\r
-# if item == 0:\r
-# dc.DrawLine(rect.x,rect.y,rect.x+rect.width,rect.y+rect.height)\r
-# elif item == 1:\r
-# half_width = rect.width / 2\r
-# dc.DrawCircle(rect.x+half_width,rect.y+half_width,half_width-3)\r
-# elif item == 2:\r
-# dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)\r
-#\r
-#\r
-#class LargeImagePickerCtrl(wx.Window):\r
-# """\\r
-# Control created and used by LargeImageEditor.\r
-# """\r
-# def __init__(self):\r
-# pre = wx.PreWindow()\r
-# self.PostCreate(pre)\r
-#\r
-# def Create(self, parent, id_, pos, size, style = 0):\r
-# wx.Window.Create(self, parent, id_, pos, size, style | wx.BORDER_SIMPLE)\r
-# img_spc = size[1]\r
-# self.tc = wx.TextCtrl(self, -1, "", (img_spc,0), (2048,size[1]), wx.BORDER_NONE)\r
-# self.SetBackgroundColour(wx.WHITE)\r
-# self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)\r
-# self.property = None\r
-# self.bmp = None\r
-# self.Bind(wx.EVT_PAINT, self.OnPaint)\r
-#\r
-# def OnPaint(self, event):\r
-# dc = wx.BufferedPaintDC(self)\r
-#\r
-# whiteBrush = wx.Brush(wx.WHITE)\r
-# dc.SetBackground(whiteBrush)\r
-# dc.Clear()\r
-#\r
-# bmp = self.bmp\r
-# if bmp:\r
-# dc.DrawBitmap(bmp, 2, 2)\r
-# else:\r
-# dc.SetPen(wx.Pen(wx.BLACK))\r
-# dc.SetBrush(whiteBrush)\r
-# dc.DrawRectangle(2, 2, 64, 64)\r
-#\r
-# def RefreshThumbnail(self):\r
-# """\\r
-# We use here very simple image scaling code.\r
-# """\r
-# if not self.property:\r
-# self.bmp = None\r
-# return\r
-#\r
-# path = self.property.DoGetValue()\r
-#\r
-# if not os.path.isfile(path):\r
-# self.bmp = None\r
-# return\r
-#\r
-# image = wx.Image(path)\r
-# image.Rescale(64, 64)\r
-# self.bmp = wx.BitmapFromImage(image)\r
-#\r
-# def SetProperty(self, property):\r
-# self.property = property\r
-# self.tc.SetValue(property.GetDisplayedString())\r
-# self.RefreshThumbnail()\r
-#\r
-# def SetValue(self, s):\r
-# self.RefreshThumbnail()\r
-# self.tc.SetValue(s)\r
-#\r
-# def GetLastPosition(self):\r
-# return self.tc.GetLastPosition()\r
-#\r
-#\r
-#class LargeImageEditor(wxpg.PyEditor):\r
-# """\\r
-# Double-height text-editor with image in front.\r
-# """\r
-# def __init__(self):\r
-# wxpg.PyEditor.__init__(self)\r
-#\r
-# def CreateControls(self, propgrid, property, pos, sz):\r
-# try:\r
-# h = 64 + 6\r
-# x = propgrid.GetSplitterPosition()\r
-# x2 = propgrid.GetClientSize().x\r
-# bw = propgrid.GetRowHeight()\r
-# lipc = LargeImagePickerCtrl()\r
-# if sys.platform == 'win32':\r
-# lipc.Hide()\r
-# lipc.Create(propgrid, wxpg.PG_SUBID1, (x,pos[1]), (x2-x-bw,h))\r
-# lipc.SetProperty(property)\r
-# # Hmmm.. how to have two-stage creation without subclassing?\r
-# #btn = wx.PreButton()\r
-# #pre = wx.PreWindow()\r
-# #self.PostCreate(pre)\r
-# #if sys.platform == 'win32':\r
-# # btn.Hide()\r
-# #btn.Create(propgrid, wxpg.PG_SUBID2, '...', (x2-bw,pos[1]), (bw,h), wx.WANTS_CHARS)\r
-# btn = wx.Button(propgrid, wxpg.PG_SUBID2, '...', (x2-bw,pos[1]), (bw,h), wx.WANTS_CHARS)\r
-# return (lipc, btn)\r
-# except:\r
-# import traceback\r
-# print traceback.print_exc()\r
-#\r
-# def UpdateControl(self, property, ctrl):\r
-# ctrl.SetValue(property.GetDisplayedString())\r
-#\r
-# def DrawValue(self, dc, property, rect):\r
-# if not (property.GetFlags() & wxpg.PG_PROP_AUTO_UNSPECIFIED):\r
-# dc.DrawText( property.GetDisplayedString(), rect.x+5, rect.y );\r
-#\r
-# def OnEvent(self, propgrid, ctrl, event):\r
-# if not ctrl:\r
-# return False\r
-#\r
-# evtType = event.GetEventType()\r
-#\r
-# if evtType == wx.wxEVT_COMMAND_TEXT_ENTER:\r
-# if propgrid.IsEditorsValueModified():\r
-# return True\r
-#\r
-# elif evtType == wx.wxEVT_COMMAND_TEXT_UPDATED:\r
-# if not property.HasFlag(wxpg.PG_PROP_AUTO_UNSPECIFIED) or not ctrl or \\r
-# ctrl.GetLastPosition() > 0:\r
-#\r
-# # We must check this since an 'empty' text event\r
-# # may be triggered when creating the property.\r
-# PG_FL_IN_SELECT_PROPERTY = 0x00100000\r
-# if not (propgrid.GetInternalFlags() & PG_FL_IN_SELECT_PROPERTY):\r
-# event.Skip();\r
-# event.SetId(propgrid.GetId());\r
-#\r
-# propgrid.EditorsValueWasModified();\r
-#\r
-# return False\r
-#\r
-#\r
-# def CopyValueFromControl(self, property, ctrl):\r
-# tc = ctrl.tc\r
-# res = property.SetValueFromString(tc.GetValue(),0)\r
-# # Changing unspecified always causes event (returning\r
-# # true here should be enough to trigger it).\r
-# if not res and property.IsFlagSet(wxpg.PG_PROP_AUTO_UNSPECIFIED):\r
-# res = True\r
-#\r
-# return res\r
-#\r
-# def SetValueToUnspecified(self, ctrl):\r
-# ctrl.tc.Remove(0,len(ctrl.tc.GetValue()));\r
-#\r
-# def SetControlStringValue(self, ctrl, txt):\r
-# ctrl.SetValue(txt)\r
-#\r
-# def OnFocus(self, property, ctrl):\r
-# ctrl.tc.SetSelection(-1,-1)\r
-# ctrl.tc.SetFocus()\r
+class PathProperty (StringProperty):\r
+ """Simple file or path property.\r
+\r
+ Currently there isn't a fancy file-picker popup. Perhaps in the\r
+ future.\r
+ """\r
+ def __init__(self, **kwargs):\r
+ super(PathProperty, self).__init__(**kwargs)\r
+ self.type = 'path'\r
\r
\r
class PropertyPanel(Panel, wx.grid.Grid):\r