Re: How prevent wxglade overwriting button handler
Dietmar Schwertberger <[email protected]>
| Newsgroups | gmane.comp.python.wxglade |
|---|---|
| Message-ID | <[email protected]> |
On 6/18/17 2:22 PM, Brendan Simon (eTRIX) wrote:
> If I create a button handler, then edit the code, then regenerate the
> code, the button handler is reset to the default.
>
> How can I prevent wxglade from overwriting MY code?
With "Overwrite existing sources" deactivated, your handler code should
be kept. The marker to detect handlers is "# wxGlade: ...<event_handler>".
I'have just tried this and noted a bug where sometimes newlines are
inserted. I will correct this asap.
Long term the keep/overwrite code needs some modifications to be more
robust and user friendly.
The alternative approach is to derive a class in your own file and
implement the handler in the derived class. For non-trivial projects
this is probably the better option.
There is a wiki page on this topic at
https://wiki.wxpython.org/OrganizingYourCode
This is a bit older and I wish it would be a bit more compact.
*In a nutshell:*
Set output file name from wxGlade to e.g. ExampleGui.py
In the main.py or Example.py:
import ExampleGui
class ExampleFrame(ExampleGUI.ExampleFrame):
def __init__(self, app):
self.app = app
ExampleGUI.ExampleFrame.__init__(self, None, wx.ID_ANY, "")
XXX implement your handlers etc. here
class ExampleApp(wx.App):
# application / logic
def OnInit(self):
self.frame = ExampleFrame(self)
self.SetTopWindow(self.frame)
self.frame.Show()
return True
Example = ExampleApp(0)
Example.MainLoop()
Regards,
Dietmar
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
wxGlade-general mailing list
wxGlade-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/wxglade-general