On Wed, 8 Nov 2006 12:51:25, wccppp@gmail.com write:
Thank you, Phil, John and Tim.
I followed Phil's 2nd suggestion and got it to work. Regarding Tim's
advice, if I use self.choice, I still won't be able to refer to it
after MainLoop, right? Since the frame instance will have been
destroyed by then.
No, that's not true. The window that it created will have been
destroyed, but the Python object (and all of its members) cannot be
destroyed until the last reference is removed. As long as you have that
variable called "frame", there is a reference, and the object will live on.
I agree that it is confusing. We want to think about a wx.Frame as
BEING the window, but that's not the case. A wx.Frame is a Python
object that just happens to CREATE a window. The lifetime of the window
and the lifetime of the object are separate.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
I followed Phil’s 2nd suggestion and got it to work. Regarding Tim’s
advice, if I use self.choice, I still won’t be able to refer to it
after MainLoop, right? Since the frame instance will have been
destroyed by then.
No, that’s not true. The window that it created will have been
destroyed, but the Python object (and all of its members) cannot be
destroyed until the last reference is removed. As long as you have that
variable called “frame”, there is a reference, and the object will live on.
I agree that it is confusing. We want to think about a wx.Frame as
BEING the window, but that’s not the case. A wx.Frame is a Python
object that just happens to CREATE a window. The lifetime of the window
and the lifetime of the object are separate.
–
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.