Today, using Wxpython to implement a simple menu, button and binding the point-and-click event and dialog output, it is very simple, but still need a good
#!/usr/bin/env python#-*-coding:utf-8-*-#-*-coding:utf-8-*-to support Chinese import osimport wxclass MainWindow (WX. Frame):d EF __init__ (self, Parent, title): WX. Frame.__init__ (self, parent, title=title,size= (500,500)) # Self.control = wx. Textctrl (self, style = wx.te_multiline) panel = wx. Panel (self) Self.setupmenubar () Self.setupbutton (panel) self. Show (True) def setupbutton (self, panel): Button = wx. button (panel, label = u "Off", pos = (), size = (+)) self. Bind (WX. Evt_button, Self.onabout, BUTTON) def setupmenubar (self): self. Createstatusbar () menubar = wx. MenuBar () Menufile = WX. Menu () Menuabout = Menufile. Append (Wx.id_abort, ' &about ', ' about this shit ') Menuexit = Menufile. Append (wx.id_exit, ' &exit ', ' End Program ') menubar. Append (Menufile, ' &file ') self. Bind (WX. Evt_menu, Self.onabout, menuabout) self. Bind (WX. Evt_menu, Self.onexit, menuexit) self. Setmenubar (menubar) def onabout (self, evt):d lg = WX. Messagedialog (Self, U ' really want to close?) ', U ' off ', WX. Yes_no | Wx. icon_question) If Wx.id_yeS = = Dlg. ShowModal (): Self. Close (True) dlg. Destroy () def onExit (self, evt): self. Close (True) def main (): App = wx. App (False) frame = MainWindow (None, ' Small Editor ') app. Mainloop () if __name__ = = ' __main__ ': Main ()
Achieve results
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Python Study the next day