I'm reading through Getting Started (http://wiki.wxpython.org). I
don't understand why the Form1 class is used directly, while other
objects first need to be instantiated as usual:
app = wx.PySimpleApp()
frame = wx.Frame(None, -1, " Quote Control") #How is Form created?
Form1(frame,-1)
frame.Show(1)
app.MainLoop()
I'd like to use wxPython to GUIfy a simple, text-based Python script
that takes a pushbutton and a label to display feedback, so this
little script looks like a good base to use.
I'm reading through Getting Started (http://wiki.wxpython.org). I
don't understand why the Form1 class is used directly, while other
objects first need to be instantiated as usual:
app = wx.PySimpleApp()
frame = wx.Frame(None, -1, " Quote Control") #How is Form created?
Form1(frame,-1)
The above line instantiates it, it just doesn't keep a reference to it and will be garbage collected as soon as the method this type of code is contained in is finished.
I would probably do it something like the attached (it is better to attach on this list, especially when things are a bit longer) shows - untested but that should give you the same result and allows you to easier use sizers.
Not quite true in this case. The C++ part of the wxPython window objects keep a reference to the Python proxy object. So the Python object will continue to exist as long as the C++ one does, which will be until the parent window is closed or destroyed, or the child is explicitly destroyed in some other way.
···
On 10/28/09 2:15 AM, werner wrote:
#How is Form created?
Form1(frame,-1)
The above line instantiates it, it just doesn't keep a reference to it
and will be garbage collected as soon as the method this type of code is
contained in is finished.