wxPython入门第二课--create menu bar (菜单栏)

我参考的的是youtu上的视频教程 ,这个仅仅作为一个个人的学习笔记作为参考

https://www.youtube.com/watch?v=8v52QIP4L9Y&list=PLejTrt5hn2r1uzZ53GDeUElXRkRFbUmQd&index=3

上面就是链接 

import wx
class bucky(wx.Frame):      

    #结构函数,这样就没必要每次都要单独执行一下
    def __init__(self,parent,id):  
        wx.Frame.__init__(self,parent,id,'Frame aka window',size=(300,200))
   
        #making a  panel
        panel=wx.Panel(self)   # self

        status=self.CreateStatusBar()   # 创建一个status bar  去承载下面的MEnubar 
        
        menubar=wx.MenuBar()    #这个相当于创建一个工具栏 一样的东西 
        
        first=wx.Menu()         # 这个是两个菜单    
        second=wx.Menu()

        menubar.Append(first,'File')    #命名
        menubar.Append(second,'edit')


        
        first.Append(wx.NewId(),'New Window','This is a new window')  #在第一个的下面,增加其他的东西
        first.Append(wx.NewId(),'open ...','This will open a new window')
        
  

        self.SetMenuBar(menubar)     # 这表示的是就是把这个menubar 放在sceen 上面。   
        


      
if __name__=='__main__':
    app=wx.App()
    frame=bucky(parent=None,id=-1)
    frame.Show()
    app.MainLoop()   #这个是用来执行这个 alpplication 的   

猜你喜欢

转载自blog.csdn.net/weixin_42066185/article/details/81171429
今日推荐