wxPython學習2005-07-21

  # Start of file
from wxPython.wx import *

ID_ABOUT = 101

ID_EXIT = 102

class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title, wxDefaultPosition, wxSize(200, 150))
self.CreateStatusBar()

self.SetStatusText("This is the statusbar")

menu = wxMenu()
menu.Append(ID_ABOUT, "&About","More information about this program")

menu.AppendSeparator()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")

menuBar = wxMenuBar()
menuBar.Append(menu, "&File");


self.SetMenuBar(menuBar)

EVT_MENU(self, ID_ABOUT, self.OnAbout)
EVT_MENU(self, ID_EXIT, self.TimeToQuit)

def OnAbout(self, event):

dlg = wxMessageDialog(self, "This sample program shows off/n"
"frames, menus, statusbars, and this/n"
"message dialog.",
"About Me", wxOK | wxICON_INFORMATION)

dlg.ShowModal()
dlg.Destroy()

def TimeToQuit(self, event):
self.Close(True)

class App(wxApp):

def OnInit(self):
frame = MyFrame(NULL, -1, "Hello from wxPython")
frame.Show(True)
self.SetTopWindow(frame)
return True


if __name__ == "__main__":
app = App(0)
app.MainLoop()

# end of file

發佈了55 篇原創文章 · 獲贊 1 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章