Python Study the next day

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.