创建菜单和状态栏控件

运行效果图:


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()



你可能感兴趣的:(创建菜单和状态栏控件)