Re: [wxPython-users] wxGlade and Events. HOW?!
by Chris Munchenberg other posts by this author
Apr 15 2003 12:10PM messages near this date
Re: [wxPython-users] wxGlade and Events. HOW?!
|
Re: [wxPython-users] wxGlade and Events. HOW?!
Fixed for a newbie, and karma now owes me.
Problems:
Python works on indentation levels. Don't screw them up - you lose =
class definitions etc.
ID_EXIT wasn't defined anywhere.
Less ugly fix:
wxGlade is great for GUI design. Do your GUI magic in another file =
that imports and uses MyFrame. Then if you need to do GUI reworking, you =
don't lose your GUI magic. wxGlade is pretty good at taking care of your =
code vs its code, but I don't trust anyone else not to overwrite my =
code.
=20
Hope this helps,
Chris.
=20
#-------------------------------------------------------------
#!/usr/bin/env python
# generated by wxGlade 0.2.1 on Tue Apr 15 13:17:17 2003
from wxPython.wx import *
ID_EXIT =3D wxNewId()
class MyFrame(wxFrame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] =3D wxDEFAULT_FRAME_STYLE
wxFrame.__init__(self, *args, **kwds)
# Menu Bar
self.frame_1_menubar =3D wxMenuBar()
self.SetMenuBar(self.frame_1_menubar)
wxglade_tmp_menu =3D wxMenu()
wxglade_tmp_menu.Append(ID_EXIT, "Exit", "Blow This Popstand!")
self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
# This is the problem generating an invalid syntax. WHY?!
EVT_MENU(self, ID_EXIT, self.OnExit)
# Menu Bar end
self.__set_properties()
self.__do_layout()
# end wxGlade
def OnExit(self, event):
self.Close(true)
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 =3D wxBoxSizer(wxVERTICAL)
self.SetAutoLayout(1)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
sizer_1.SetSizeHints(self)
self.Layout()
# end wxGlade
# end of class MyFrame
class DemoApp(wxApp):
def OnInit(self):
frame =3D MyFrame(None, -1, "Test Frame")
frame.Show(True)
self.SetTopWindow(frame)
return True
def main():
app =3D DemoApp(0)
app.MainLoop()
if __name__ =3D=3D '__main__':
main()
----- Original Message -----=20
From: Eladio Ventura=20
To: wxPython=20
Sent: Tuesday, April 15, 2003 10:53 PM
Subject: [wxPython-users] wxGlade and Events. HOW?!
I'm messing around with wxGlade for some instant gratification, but I =
simply
can't figure out how to add events to my app. For instance, I'd like to =
add a
simple menu-event to gracefully close down the app, but no matter where =
I put
the EVT_MENU, the interpreter bitches about an invalid syntax. No matter =
what I
do to correct the syntax, I get the same error message. I've tried to =
put in in
__set_properties() and __do_layout(), but nothing helped.
Score some karma and help out a newbie, will ya'?!
#-------------------------------------------------------------
#!/usr/bin/env python
# generated by wxGlade 0.2.1 on Tue Apr 15 13:17:17 2003
from wxPython.wx import *
class MyFrame(wxFrame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] =3D wxDEFAULT_FRAME_STYLE
wxFrame.__init__(self, *args, **kwds)
=20
# Menu Bar
self.frame_1_menubar =3D wxMenuBar()
self.SetMenuBar(self.frame_1_menubar)
wxglade_tmp_menu =3D wxMenu()
wxglade_tmp_menu.Append(ID_EXIT, "Exit", "Blow This Popstand!")
self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
# This is the problem generating an invalid syntax. WHY?!
EVT_MENU(self, ID_EXIT, self.OnExit)
# Menu Bar end
self.__set_properties()
self.__do_layout()
# end wxGlade
def OnExit(self, event):
self.Close(true)=20
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 =3D wxBoxSizer(wxVERTICAL)
self.SetAutoLayout(1)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
sizer_1.SetSizeHints(self)
self.Layout()
# end wxGlade
# end of class MyFrame
--=20
"Thinking gives you wrinkles!"
Malibu Stacy, the Simpsons
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@[...].org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
Thread:
Eladio Ventura
Frank Millman
Chris Munchenberg
Eladio Ventura
Eladio Ventura
Robin Dunn
Chris Munchenberg
Eladio Ventura
Chris Munchenberg
Eladio Ventura
Eladio Ventura
Alberto Griggio
Frank Millman
Robin Dunn
|