diff --git a/demo/PropertyGrid.py b/demo/PropertyGrid.py index 6815e05a..e9946e4a 100644 --- a/demo/PropertyGrid.py +++ b/demo/PropertyGrid.py @@ -319,6 +319,7 @@ class SampleMultiButtonEditor(wxpg.PGTextCtrlEditor): property, pos, buttons.GetPrimarySize()) + wnd = wnd.m_primary # Finally, move buttons-subwindow to correct position and make sure # returned wxPGWindowList contains our custom button list. @@ -331,7 +332,7 @@ class SampleMultiButtonEditor(wxpg.PGTextCtrlEditor): # PGMultiButton instance. self.buttons = buttons - return (wnd, buttons) + return wxpg.PGWindowList(wnd, buttons) def OnEvent(self, propGrid, prop, ctrl, event): if event.GetEventType() == wx.wxEVT_COMMAND_BUTTON_CLICKED: @@ -429,7 +430,7 @@ class TrivialPropertyEditor(wxpg.PGEditor): btn = wx.Button(propgrid.GetPanel(), wxpg.PG_SUBID2, '...', (x+w, y), (bw, h), wx.WANTS_CHARS) - return (tc, btn) + return wxpg.PGWindowList(tc, btn) except: import traceback print(traceback.print_exc()) @@ -503,8 +504,7 @@ class LargeImagePickerCtrl(wx.Panel): Control created and used by LargeImageEditor. """ def __init__(self): - pre = wx.PrePanel() - self.PostCreate(pre) + wx.Panel.__init__(self) def Create(self, parent, id_, pos, size, style = 0): wx.Panel.Create(self, parent, id_, pos, size, @@ -586,18 +586,10 @@ class LargeImageEditor(wxpg.PGEditor): lipc.Hide() lipc.Create(propgrid.GetPanel(), wxpg.PG_SUBID1, (x,y), (w,h)) lipc.SetProperty(property) - # Hmmm.. how to have two-stage creation without subclassing? - #btn = wx.PreButton() - #pre = wx.PreWindow() - #self.PostCreate(pre) - #if sys.platform == 'win32': - # btn.Hide() - #btn.Create(propgrid, wxpg.PG_SUBID2, '...', (x2-bw,pos[1]), - # (bw,h), wx.WANTS_CHARS) btn = wx.Button(propgrid.GetPanel(), wxpg.PG_SUBID2, '...', (x+w, y), (bw, h), wx.WANTS_CHARS) - return (lipc, btn) + return wxpg.PGWindowList(lipc, btn) except: import traceback print(traceback.print_exc()) diff --git a/etg/_propgrid.py b/etg/_propgrid.py index b8fc5e12..8dcbb8e0 100644 --- a/etg/_propgrid.py +++ b/etg/_propgrid.py @@ -66,6 +66,9 @@ def run(): module.addInclude(INCLUDES) + module.addInitializerCode("""\ + wxPGInitResourceModule(); + """) #----------------------------------------------------------------- tools.doCommonTweaks(module) diff --git a/etg/propgrid.py b/etg/propgrid.py index 530aea03..d1094cff 100644 --- a/etg/propgrid.py +++ b/etg/propgrid.py @@ -44,8 +44,9 @@ def run(): tools.fixWindowClass(c) module.addGlobalStr('wxPropertyGridNameStr', c) - for m in c.find('RegisterEditorClass').all(): - m.find('editor').transfer = True + for name in ['RegisterEditorClass', 'DoRegisterEditorClass']: + for m in c.find(name).all(): + m.find('editor').transfer = True # TODO: provide a way to use a Python callable as a sort function @@ -100,6 +101,13 @@ def run(): EVT_PG_COL_END_DRAG = wx.PyEventBinder( wxEVT_PG_COL_END_DRAG, 1 ) """) + module.addItem(etgtools.WigCode("""\ + enum { + wxPG_SUBID1, + wxPG_SUBID2, + wxPG_SUBID_TEMP1, + }; + """)) # Switch all wxVariant types to wxPGVariant, so the propgrid-specific # version of the MappedType will be used for converting to/from Python diff --git a/etg/propgrideditors.py b/etg/propgrideditors.py index ef7dc83d..88263b77 100644 --- a/etg/propgrideditors.py +++ b/etg/propgrideditors.py @@ -40,10 +40,42 @@ def run(): # Tweak the parsed meta objects in the module object as needed for # customizing the generated code and docstrings. + + c = module.find('wxPGEditor') + assert isinstance(c, etgtools.ClassDef) + + # Change the method to return the value instead of passing it + # through a parameter for modification. + m = c.find('GetValueFromControl') + m.find('variant').out = True + + # Change the virtual method handler code to follow the same pattern as the + # tweaked public API, namely that the value is the return value instead of + # an out parameter. + m.cppSignature = 'bool (wxVariant& variant, wxPGProperty* property, wxWindow* ctrl)' + m.virtualCatcherCode = """\ + PyObject *sipResObj = sipCallMethod(0, sipMethod, "DDD", + property, sipType_wxPGProperty, NULL, + ctrl, sipType_wxWindow, NULL); + if (sipResObj == Py_None) { + sipRes = false; + } else { + sipParseResult(&sipIsErr, sipMethod, sipResObj, "bH5", &sipRes, sipType_wxPGVariant, &variant); + } + """ + + c = module.find('wxPGMultiButton') assert isinstance(c, etgtools.ClassDef) tools.fixWindowClass(c) + c.addPyMethod('AddButton', '(self, label, id=-2)', + doc='A simple wrapper around the PGMultiButton.Add method, for backwards compatibility.', + body="self.Add(label, id)") + + c.addPyMethod('AddBitmapButton', '(self, bitmap, id=-2)', + doc='A simple wrapper around the PGMultiButton.Add method, for backwards compatibility.', + body="self.Add(bitmap, id)") # Switch all wxVariant types to wxPGVariant, so the propgrid-specific # version of the MappedType will be used for converting to/from Python