Python's Wxpython menu using the detailed

Source: Internet
Author: User

Import WX App_exit=1 #定义一个控件ID class Example (WX. Frame): Def __init__ (self, parent, ID, title): Super (Example,self). __INIT__ (parent, ID, title) #调用你类的初始化 Sel F.initui () #调用自身的函数 def initui (self): #自定义的函数, complete the settings for the menu menubar = wx. MenuBar () #生成菜单栏 filemenu = wx. Menu () #生成一个菜单 QMI = wx. MenuItem (Filemenu, App_exit, "Quit") #生成一个菜单项 Qmi. SetBitmap (WX. Bitmap ("2.bmp")) #给菜单项前面加个小图标 Filemenu. Appenditem (QMI) #把菜单项加入到菜单中 menubar. Append (Filemenu, "&file") #把菜单加入到菜单栏中 self. Setmenubar (menubar) #把菜单栏加入到Frame框架中 self. Bind (WX. Evt_menu, self. OnQuit, Id=app_exit) #给菜单项加入事件处理 self. SetSize (()) #设置下Frame的大小, title, and center align Self. Settitle ("simple Menu") self. Centre () self. Show (True) #显示框架 def onquit (self, e): #自定义函数 response menu item self. Close () def main (): ex = WX. APP () #生成一个应用程序 Example (None, Id=-1, title= "main") #调用我们的类 ex. Mainloop () #消息循环 if __name__ = = "__main__": Main ()

The effect is as follows:

Python's Wxpython menu using the detailed

Related Article

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.