运行效果图:


Python代码:

#!/usr/bin/env python
# -*- encoding:utf-8 -*-
'Create Menu Example'

import wx

class MyFrame(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'Create Menu',size=(300,200))
        panel=wx.Panel(self)

        status=self.CreateStatusBar()#创建状态栏
        menubar=wx.MenuBar()#创建菜单栏
        first=wx.Menu()#创建菜单
        second=wx.Menu()
        first.Append(wx.NewId(),'New Window','This is a new window')#增加菜单项
        first.Append(wx.NewId(),'Open...','This will open a new window')
        menubar.Append(first,'File')#把菜单项加入到file菜单
        menubar.Append(second,'Edit')#edit菜单
        self.SetMenuBar(menubar)

if __name__=='__main__':
    app=wx.PySimpleApp()
    myframe=MyFrame(parent=None,id=-1)
    myframe.Show(True)
    app.MainLoop()



Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐