zoukankan      html  css  js  c++  java
  • wxpython 给框架增加菜单栏,工具栏和状态栏

    # _*_ coding: utf-8 _*_
    __author__ = 'pythonwu'
    __date__ = "2018/5/15 16:20"

    import wx
    from wx.py.shell import ShellFrame
    from wx.py.filling import FillingFrame
    import wx.py.images as images

    class ToolBarFrame(wx.Frame):
    def __init__(self,parent,id):
    wx.Frame.__init__(self,parent,id,'Toolbars',size = (300,200))
    panel = wx.Panel(self)
    panel.SetBackgroundColour('White')
    statusBar = self.CreateStatusBar() #创建状态栏
    toolBar = self.CreateToolBar() #创建工具栏
    toolBar.AddSimpleTool(wx.NewId(),images.getPyBitmap(),"New","Long help for 'New'") #给工具栏增加一个工具
    toolBar.Realize() #准备显示工具栏
    menuBar = wx.MenuBar() #创建菜单栏
    #创建两个菜单
    menu1 = wx.Menu()
    menuBar.Append(menu1,"&File")
    menu2 = wx.Menu()
    #创建菜单的项目
    menu2.Append(wx.NewId(),"&Copy","Copy in status bar")
    menu2.Append(wx.NewId(),"C&ut","")
    menu2.Append(wx.NewId(),"Paste","")
    menu2.AppendSeparator()
    menu2.Append(wx.NewId(),"&Options","Display Options")
    menuBar.Append(menu2,"&Edit") #在菜单栏上附上菜单
    #创建debug菜单及其菜单项
    menu3 = wx.Menu()
    shell = menu3.Append(-1,"&wxPython sehll","Open wxPython shell frame")
    filling = menu3.Append(-1,"&Namespace viewer","OPen namespace viewer frame")
    menuBar.Append(menu3,"&Debug")
    #设置菜单的事件处理器
    self.Bind(wx.EVT_MENU,self.OnShell,shell)
    self.Bind(wx.EVT_MENU,self.OnFilling,filling)
    self.SetMenuBar(menuBar)
    #消息对话框
    # dlg = wx.MessageDialog(panel,"Is this the coolest thing ever!","MessageDialog",wx.YES_NO|wx.ICON_QUESTION)
    # result = dlg.ShowModal()
    # dlg.Destroy()
    #文本输入对话框
    # dlg = wx.TextEntryDialog(panel,"Is this the coolest thing ever!","MessageDialog",'Gary')
    # if dlg.ShowModal()== wx.ID_OK:
    # response = dlg.GetValue()
    #从一个列表中选择
    # dlg = wx.SingleChoiceDialog(panel,"Is this the coolest thing ever!","MessageDialog",['1','2','3'])
    # if dlg.ShowModal()== wx.ID_OK:
    # response = dlg.GetStringSelection()
    def OnCloseMe(self,e):
    self.Close(True)
    def OnCloseWindow(self,e):
    self.Destroy()
    # OnShell菜单项和OnFilling菜单项处理器
    def OnShell(self,e):
    frame = ShellFrame(parent=self)
    frame.Show()
    def OnFilling(self,e):
    frame = FillingFrame(parent=self)
    frame.Show()

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

    """
    ShowModal()方法将对话框以模式框架的方式显示,这意味着在对话框关
    闭之前,应用程序中的别的窗口不能响应用户事件。ShowModal()方法的返回
    值是一个整数,对于wx.MessageDialog,返回值是下面常量之
    一: wx.ID_YES, wx.ID_NO, wx.ID_CANCEL, wx.ID_OK。
    """
  • 相关阅读:
    spring Cloud中,解决Feign/Ribbon整合Hystrix第一次请求失败的问题?
    spring boot集成mybatis
    feign实现服务间的负载均衡
    如何解决Eureka Server不踢出已关停的节点的问题?
    spring-cloud-ribbon负载均衡
    安装配置php5.4 win2003
    ThinkPHP3.2 G函数代码及 使用方法
    php获取数组第一个值 current()
    checkbox全选,反选,取消选择 jquery
    JavaScript If...Else 语句
  • 原文地址:https://www.cnblogs.com/wudeng/p/9051525.html
Copyright © 2011-2022 走看看