Hello wxPython-users,
How to I get/catch the frame close event ?
Thanx.
···
--
Best regards,
fowlertrainer mailto:fowlertrainer@anonym.hu
Hello wxPython-users,
How to I get/catch the frame close event ?
Thanx.
--
Best regards,
fowlertrainer mailto:fowlertrainer@anonym.hu
From: fowlertrainer@anonym.hu [mailto:fowlertrainer@anonym.hu]
Hello wxPython-users,
How to I get/catch the frame close event ?
In the frame, set up an event handler, such as:
def onClose(self, evt):
<your code here>
And in the frame's init, bind the event to that handler:
EVT_CLOSE(self, self.onClose)
How do I use an event called function in a menu, using my own parameters,
for instance in the example below, how do I call the OnAdd function:
from wxPython.wx import *
ID_ADD = 101
ID_EXIT = 102
class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition, wxSize(200, 150))
x = 2
y = 5
menu = wxMenu()
menu.Append(ID_ADD, "&Add",
"Add x and y")
menu.AppendSeparator()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")
menuBar = wxMenuBar()
menuBar.Append(menu, "&Do something")
EVT_MENU(self, ID_ADD, self.OnAdd)
EVT_MENU(self, ID_EXIT, self.OnExit)
self.SetMenuBar(menuBar)
def OnExit(self, event):
self.Close(true)
def OnAdd(self, event, x, y):
self.log.write('x plus y equals:%d\n' % (x + y) )
def OnInit(self):
self.log.write('Not yet available\n')
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Test")
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
how about using self ?
define x/y as
self.x=2
self.y=5
and
def onAdd(self,event):
self.log.write('x plus y equals:%d\n' % (self.x + self.y) )
How do I use an event called function in a menu, using my own parameters,
for instance in the example below, how do I call the OnAdd function:from wxPython.wx import *
ID_ADD = 101
ID_EXIT = 102class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition, wxSize(200, 150))
x = 2
y = 5menu = wxMenu()
menu.Append(ID_ADD, "&Add",
"Add x and y")
menu.AppendSeparator()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")menuBar = wxMenuBar()
menuBar.Append(menu, "&Do something")EVT_MENU(self, ID_ADD, self.OnAdd)
EVT_MENU(self, ID_EXIT, self.OnExit)self.SetMenuBar(menuBar)
def OnExit(self, event):
self.Close(true)def OnAdd(self, event, x, y):
self.log.write('x plus y equals:%d\n' % (x + y) )def OnInit(self):
self.log.write('Not yet available\n')class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Test")
frame.Show(true)
self.SetTopWindow(frame)
return trueapp = MyApp(0)
app.MainLoop()---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
- --
UC
- --
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417
On Tuesday 09 December 2003 08:35 pm, Henry Grantham wrote: