Hello Guys, I have problem with Bindinging Event to menu. Every time I run this on IDLE (F5). I get always Attribute error that self have no attribute OnPrint. What's wrong with the Code????
# SMD Inc since 2003.py
import wx
ID_ABOUT = 100
ID_PRINT = 101
ID_EXIT =102
class MainWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(500, 350))
self.CreateStatusBar()
self.SetStatusText("Displays program Information")
menubar = wx.MenuBar()
# File menu
filemenu = wx.Menu()
filemenu.Append(ID_PRINT, "&Print", "Print the current Window")
filemenu.Append(ID_EXIT, "E&xit", "Exit the program")
menubar.Append(filemenu, "&File")
# Help Menu
helpmenu = wx.Menu()
helpmenu.Append(ID_ABOUT, "&File", "About this program")
menubar.Append(helpmenu, "He&lp")
# Attach and set Menubar on Frame
self.SetMenuBar(menubar)
# Binding Events
self.Bind(wx.EVT_MENU, self.OnPrint, ID_PRINT)
self.Centre()
self.Show(True)
# Setting methods
def OnPrint(self, event):
self.close()
dia = wx.MessageDialog(self, "Thank you!", "About the program", wx.OK)
dia.ShowModal()
dia.Destroy()
app = wx.App()
MainWindow(None, -1, "Elijah's SMD Inc. since 2003")
app.MainLoop()
Steve