-
The line:
self.SetMenuBar(menu_bar)
Should instead be:
self.SetMenuBar(self.menu_bar)
because you defined it as self.menu_bar, not just menu_bar
-
The lines:
def
OnCloseWindow(self,event):
self.Close()
Should be (I think):
def
OnCloseWindow(self,event):
self.Destroy()
···
On Sat, Feb 23, 2008 at 2:38 AM, Sagar Khushalani s.khushalani@yahoo.co.uk wrote:
hi all,
i’m running wxPython on windows xp, ide = activepython.
everytime i run the program it crashes. i’m not really getting why thats happening since i havent even start the major portion of the program yet. i’ve only created a menu bar and a status bar. do i need to use another ide? i’m relatively new at wxPython and any help is really really appreciated.
-Sagar
import os, wx, win32com.client
class MainWindow(wx.Frame):
def init(self,parent,ID,title):
wx.Frame.init(self,parent,ID,title,size=(800,600),style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
self.SetMinSize((400,320)) self.Bind(wx.EVT_CLOSE,self.OnCloseWindow)
self.CreateStatusBar() self.SetStatusText("Click the buttons to start the processes") self.menu_bar = wx.MenuBar() menu1 = wx.Menu() menu1.Append(101,"&About") menu1.AppendSeparator() menu1.Append(102,"&Exit") self.Bind(wx.EVT_MENU,self.about,id=101) self.Bind(wx.EVT_MENU,self.OnCloseWindow,id=102) self.menu_bar.Append(menu1,"&File") self.SetMenuBar(menu_bar)
def
OnCloseWindow(self,event):
self.Close()
def about(self,event):
pass
class MainApp(wx.App):
def OnInit(self):
main = MainWindow(None,-1,“Lab I”)self.SetTopWindow(main) main.Show(True) return True
def main():
app = MainApp(0)
app.MainLoop()if name == ‘main’:
main()
Sagar Khushalani
Graduate Student, UTA
Networking / Systems and Architecture
s.khushalani@yahoo.co.uk
Sent from Yahoo! Mail.
A Smarter Inbox.