[Tutor] First step
SA
sarmstrong13@mac.com
Thu, 15 Aug 2002 07:25:12 -0500
On 8/15/02 5:27 AM, "Pol Branckotte" <polbranckotte@skynet.be> wrote:
> I just try to define a window and later decide to make it visible:
> Here are the two programs, I can understand the error message generated by the
> first
> but not the one generated by the second
> What am I missing?
> How to make it happen?
>
>
> from wxPython.wx import *
>
> class MyApp(wxApp):
> def OnInit(self):
> frame = wxFrame(NULL, -1, "hello from wxPy")
> #frame.Show(true)
> self.SetTopWindow(frame)
> return true
>
> app = MyApp(0)
> app.frame.Show(true)
> app.MainLoop()
>
> attribute error: MyApp instance has no attribute 'frame'
> __________________________________________________
>
> from wxPython.wx import *
>
> class MyApp(wxApp):
> def OnInit(self):
> frame = wxFrame(NULL, -1, "hello from wxPy")
> #frame.Show(true)
> self.SetTopWindow(frame)
> return true
>
> app = MyApp(0)
> frame.Show(true)
> app.MainLoop()
>
> name error name "frame" is not defined
>
>
Well, first it looks like app = MyApp(0) is passing the value 0 to wxApp.
I'm not 100% sure on this.
But I can tell you python is giving you the correct response. There is no
attribute frame because frame is not defined in the instance.
app.frame.Show(true) should be:
app.OnInit(true)
OnInit is the attribute frame is part of the function Oninit. (I believe)
Gregor is correct. Look back at the few emails I have been conversing with
Magnus on this very subject.
Good Luck.
SA
--
"I can do everything on my Mac I used to on my PC. Plus a lot more ..."
-Me