Python wx 模块,Menu() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.Menu()

项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def wxPythonApp():
    import wx
    app = wx.App()
    frame = wx.Frame(None, -1, "wxPython GUI", size=(200,150))
    frame.SetBackgroundColour('white')
    frame.CreateStatusBar()
    menu= wx.Menu()
    menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
    menuBar = wx.MenuBar()
    menuBar.Append(menu,"File") 
    frame.SetMenuBar(menuBar)     
    frame.Show()

    runT = Thread(target=app.MainLoop)
    runT.setDaemon(True)    
    runT.start()
    print(runT)
    print('createThread():', runT.isAlive())
项目:nodemcu-pyflasher    作者:marcelstoer    | 项目源码 | 文件源码
def _build_menu_bar(self):
        self.menuBar = wx.MenuBar()

        # File menu
        file_menu = wx.Menu()
        wx.App.SetMacExitMenuItemId(wx.ID_EXIT)
        exit_item = file_menu.Append(wx.ID_EXIT, "E&xit\tCtrl-Q", "Exit NodeMCU PyFlasher")
        exit_item.SetBitmap(images.Exit.GetBitmap())
        self.Bind(wx.EVT_MENU, self._on_exit_app, exit_item)
        self.menuBar.Append(file_menu, "&File")

        # Help menu
        help_menu = wx.Menu()
        help_item = help_menu.Append(wx.ID_ABOUT, '&About NodeMCU PyFlasher', 'About')
        self.Bind(wx.EVT_MENU, self._on_help_about, help_item)
        self.menuBar.Append(help_menu, '&Help')

        self.SetMenuBar(self.menuBar)
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        imageFile = 'Tile.bmp'
        self.bmp = wx.Bitmap(imageFile)
        # react to a resize event and redraw image
        parent.Bind(wx.EVT_SIZE, self.canvasCallback)

        menu = wx.Menu()
        menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
        menu.AppendSeparator()
        menu.Append(wx.ID_EXIT, "Exit", " Exit the GUI")
        menuBar = wx.MenuBar()
        menuBar.Append(menu, "File") 
        parent.SetMenuBar(menuBar)  

        self.textWidget = wx.TextCtrl(self, size=(280, 80), style=wx.TE_MULTILINE)

        button = wx.Button(self, label="Create OpenGL 3D Cube", pos=(60, 100))
        self.Bind(wx.EVT_BUTTON, self.buttonCallback, button)  

        parent.CreateStatusBar()
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        menu = wx.Menu()
        menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
        menu.AppendSeparator()
        menu.Append(wx.ID_EXIT, "Exit", " Exit the GUI")
        menuBar = wx.MenuBar()
        menuBar.Append(menu, "File") 
        parent.SetMenuBar(menuBar)  

        self.textWidget = wx.TextCtrl(self, size=(280, 80), style=wx.TE_MULTILINE)

        button = wx.Button(self, label="Create OpenGL 3D Cube", pos=(60, 100))
        self.Bind(wx.EVT_BUTTON, self.buttonCallback, button)  

        parent.CreateStatusBar()
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def OnInit(self):
        frame = wx.Frame(None, -1, "RunDemo: ", pos=(0,0),
                        style=wx.DEFAULT_FRAME_STYLE, name="run a sample")

        menuBar = wx.MenuBar()
        menu = wx.Menu()
        item = menu.Append(wx.ID_EXIT, "E&xit", "Exit demo")
        self.Bind(wx.EVT_MENU, self.OnExitApp, item)
        menuBar.Append(menu, "&File")

        frame.SetMenuBar(menuBar)
        frame.Show(True)
        frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame)

        win = runTest(frame)

        # set the frame to a good size for showing the two buttons
        frame.SetSize((200,400))
        win.SetFocus()
        self.window = win
        frect = frame.GetRect()

        self.SetTopWindow(frame)
        self.frame = frame
        return True
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def createMenus(self):
        # Creating the menubar.
        menuBar = wx.MenuBar()

        # Setting up the menu.
        filemenu = wx.Menu()
        filemenu.Append(ID_MENU_FILE_READ, "Read"," Read last numbers dialed SIM.")
        filemenu.AppendSeparator()
        filemenu.Append(ID_MENU_FILE_EXPORT, "Export..."," Export your LND to file")
        filemenu.Append(ID_MENU_FILE_IMPORT, "Import..."," Import your LND from file")
        filemenu.AppendSeparator()
        filemenu.Append(ID_MENU_FILE_EXIT, "Close"," Close the lnd")
        # Adding the "filemenu" to the MenuBar
        menuBar.Append(filemenu,"&File")

        # Adding the MenuBar to the Frame content.
        self.SetMenuBar(menuBar)

        #Add the menu handlers
        wx.EVT_MENU(self, ID_MENU_FILE_READ, self.read)
        wx.EVT_MENU(self, ID_MENU_FILE_EXPORT, self.doExport)
        wx.EVT_MENU(self, ID_MENU_FILE_IMPORT, self.doImport)
        wx.EVT_MENU(self, ID_MENU_FILE_EXIT, self.closeWindow)
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def createMenus(self):
        # Creating the menubar.
        menuBar = wx.MenuBar()

        # Setting up the menu.
        filemenu = wx.Menu()
        filemenu.Append(ID_MENU_FILE_READ, "Read"," Read your phonebook contacts from your SIM.")
        filemenu.AppendSeparator()
        filemenu.Append(ID_MENU_FILE_EXPORT, "Export..."," Export your phone contacts to file")
        filemenu.Append(ID_MENU_FILE_IMPORT, "Import..."," Import your phone contacts from file")
        filemenu.AppendSeparator()
        filemenu.Append(ID_MENU_FILE_EXIT, "Close"," Close the phonebook")
        # Adding the "filemenu" to the MenuBar
        menuBar.Append(filemenu,"&File")

        # Adding the MenuBar to the Frame content.
        self.SetMenuBar(menuBar)

        #Add the menu handlers
        wx.EVT_MENU(self, ID_MENU_FILE_READ, self.read)
        wx.EVT_MENU(self, ID_MENU_FILE_EXPORT, self.doExport)
        wx.EVT_MENU(self, ID_MENU_FILE_IMPORT, self.doImport)
        wx.EVT_MENU(self, ID_MENU_FILE_EXIT, self.closeWindow)
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def _build_menu(self):
        """Build the application menu."""
        menubar = wx.MenuBar()
        file_menu = wx.Menu()
        help_menu = wx.Menu()

        self.Bind(wx.EVT_MENU, self._directory_chooser, file_menu.Append(wx.ID_OPEN, 'Open directory...'))
        self.Bind(wx.EVT_MENU, self._open_settings, file_menu.Append(wx.ID_PROPERTIES, 'Settings...'))
        file_menu.AppendSeparator()
        self.Bind(wx.EVT_MENU, lambda evt: self.Close(), file_menu.Append(wx.ID_EXIT))
        self.Bind(wx.EVT_MENU, self._open_about, help_menu.Append(wx.ID_ABOUT))
        self.Bind(wx.EVT_MENU, lambda evt: wx.LaunchDefaultBrowser("http://irida-miseq-uploader.readthedocs.io/en/latest/"), help_menu.Append(wx.ID_HELP))

        menubar.Append(file_menu, '&File')
        menubar.Append(help_menu, '&Help')
        self.SetMenuBar(menubar)
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def init_settings_popup_menu(self):
        menu = wx.Menu()
        menu.Append(wx.NewId(), 'Show in GUI:').Enable(False)
        wx_id = wx.NewId()
        self.settings_menu_sky_item = menu.AppendCheckItem(wx_id, '   Sky')
        wx.EVT_MENU(menu, wx_id, self.on_settings_menu_sky_item)
        self.settings_menu_sky_item.Check(True)
        wx_id = wx.NewId()
        self.settings_menu_flat_item = menu.AppendCheckItem(wx_id, '   Flat')
        wx.EVT_MENU(menu, wx_id, self.on_settings_menu_flat_item)
        self.settings_menu_flat_item.Check(True)
        wx_id = wx.NewId()
        self.settings_menu_autoload_item = menu.AppendCheckItem(wx_id, '   Auto-load')
        wx.EVT_MENU(menu, wx_id, self.on_settings_menu_autoload_item)
        self.settings_menu_autoload_item.Check(True)
        wx_id = wx.NewId()
        self.settings_menu_activemq_item = menu.AppendCheckItem(wx_id, '   ActiveMQ')
        wx.EVT_MENU(menu, wx_id, self.on_settings_menu_activemq_item)
        self.settings_menu_activemq_item.Check(True)
        self.settings_popup_menu = menu
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def init_cmap_popup_menu(self):
        cmap_button_bitmap_height = 10
        cmap_button_bitmap_width = 200
        cmap_menu_bitmap_height = 20
        cmap_menu_bitmap_width = 200
        self.cmap_button_bitmaps = {}
        self.cmap_menu_bitmaps = {}
        for cmap in self.ztv_frame.available_cmaps:
            temp = cm.ScalarMappable(cmap=cmap)
            rgba = temp.to_rgba(np.outer(np.ones(cmap_button_bitmap_height, dtype=np.uint8),
                                         np.arange(cmap_button_bitmap_width, dtype=np.uint8)))
            self.cmap_button_bitmaps[cmap] = wx.BitmapFromBufferRGBA(cmap_button_bitmap_width, cmap_button_bitmap_height,
                                                                     np.uint8(np.round(rgba*255)))
            rgba = temp.to_rgba(np.outer(np.ones(cmap_menu_bitmap_height, dtype=np.uint8),
                                         np.arange(cmap_menu_bitmap_width, dtype=np.uint8)))
            self.cmap_menu_bitmaps[cmap] = wx.BitmapFromBufferRGBA(cmap_menu_bitmap_width, cmap_menu_bitmap_height,
                                                                   np.uint8(np.round(rgba*255)))
        menu = wx.Menu()
        for cmap in self.ztv_frame.available_cmaps:
            menu_item = menu.AppendCheckItem(self.cmap_to_eventID[cmap], cmap)
            wx.EVT_MENU(menu, self.cmap_to_eventID[cmap], self.on_change_cmap_event)
            if hasattr(menu_item, 'SetBitmap'):
                menu_item.SetBitmap(self.cmap_menu_bitmaps[cmap])
        self.cmap_popup_menu = menu
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def init_settings_popup_menu(self):
        menu = wx.Menu()
        menu.Append(wx.NewId(), 'Show in GUI:').Enable(False)
        wx_id = wx.NewId()
        self.settings_menu_sky_item = menu.AppendCheckItem(wx_id, '   Sky')
        wx.EVT_MENU(menu, wx_id, self.on_settings_menu_sky_item)
        self.settings_menu_sky_item.Check(True)
        wx_id = wx.NewId()
        self.settings_menu_flat_item = menu.AppendCheckItem(wx_id, '   Flat')
        wx.EVT_MENU(menu, wx_id, self.on_settings_menu_flat_item)
        self.settings_menu_flat_item.Check(True)
        wx_id = wx.NewId()
        self.settings_menu_autoload_item = menu.AppendCheckItem(wx_id, '   Auto-load')
        wx.EVT_MENU(menu, wx_id, self.on_settings_menu_autoload_item)
        self.settings_menu_autoload_item.Check(True)
        wx_id = wx.NewId()
        self.settings_menu_activemq_item = menu.AppendCheckItem(wx_id, '   ActiveMQ')
        wx.EVT_MENU(menu, wx_id, self.on_settings_menu_activemq_item)
        self.settings_menu_activemq_item.Check(True)
        self.settings_popup_menu = menu
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def CheckSaveBeforeClosing(self, title=_("Close Project")):
        """Function displaying an question dialog if project is not saved"

        :returns: False if closing cancelled.
        """
        if not self.Controler.ProjectIsSaved():
            dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), title, wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
            answer = dialog.ShowModal()
            dialog.Destroy()
            if answer == wx.ID_YES:
                self.SaveProject()
            elif answer == wx.ID_CANCEL:
                return False

        for idx in xrange(self.TabsOpened.GetPageCount()):
            window = self.TabsOpened.GetPage(idx)
            if not window.CheckSaveBeforeClosing():
                return False

        return True

    # -------------------------------------------------------------------------------
    #                            File Menu Functions
    # -------------------------------------------------------------------------------
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def GenerateTreeMenu(self, x, y, scaling, menu, base_path, var_class, tree):
        for child_name, child_type, (child_tree, child_dimensions) in tree:
            if base_path:
                child_path = "%s.%s" % (base_path, child_name)
            else:
                child_path = child_name
            if len(child_dimensions) > 0:
                child_path += "[%s]" % ",".join([str(dimension[0]) for dimension in child_dimensions])
                child_name += "[]"
            new_id = wx.NewId()
            AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=child_name)
            self.ParentWindow.Bind(wx.EVT_MENU, self.GetAddVariableBlockFunction(x, y, scaling, var_class, child_path, child_type), id=new_id)
            if len(child_tree) > 0:
                new_id = wx.NewId()
                child_menu = wx.Menu(title='')
                self.GenerateTreeMenu(x, y, scaling, child_menu, child_path, var_class, child_tree)
                menu.AppendMenu(new_id, "%s." % child_name, child_menu)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def AddBlockPinMenuItems(self, menu, connector):
        [ID_NO_MODIFIER, ID_NEGATED, ID_RISING_EDGE,
         ID_FALLING_EDGE] = [wx.NewId() for i in xrange(4)]

        # Create menu items
        self.AddMenuItems(menu, [
            (ID_NO_MODIFIER, wx.ITEM_RADIO, _(u'No Modifier'), '', self.OnNoModifierMenu),
            (ID_NEGATED, wx.ITEM_RADIO, _(u'Negated'), '', self.OnNegatedMenu),
            (ID_RISING_EDGE, wx.ITEM_RADIO, _(u'Rising Edge'), '', self.OnRisingEdgeMenu),
            (ID_FALLING_EDGE, wx.ITEM_RADIO, _(u'Falling Edge'), '', self.OnFallingEdgeMenu)])

        type = self.Controler.GetEditedElementType(self.TagName, self.Debug)
        menu.Enable(ID_RISING_EDGE, type != "function")
        menu.Enable(ID_FALLING_EDGE, type != "function")

        if connector.IsNegated():
            menu.Check(ID_NEGATED, True)
        elif connector.GetEdge() == "rising":
            menu.Check(ID_RISING_EDGE, True)
        elif connector.GetEdge() == "falling":
            menu.Check(ID_FALLING_EDGE, True)
        else:
            menu.Check(ID_NO_MODIFIER, True)

    # Add Alignment Menu items to the given menu
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def AddAlignmentMenuItems(self, menu):
        [
            ID_ALIGN_LEFT, ID_ALIGN_CENTER, ID_ALIGN_RIGHT,
            ID_ALIGN_TOP, ID_ALIGN_MIDDLE, ID_ALIGN_BOTTOM,
        ] = [wx.NewId() for i in xrange(6)]

        # Create menu items
        self.AddMenuItems(menu, [
            (ID_ALIGN_LEFT, wx.ITEM_NORMAL, _(u'Left'), '', self.OnAlignLeftMenu),
            (ID_ALIGN_CENTER, wx.ITEM_NORMAL, _(u'Center'), '', self.OnAlignCenterMenu),
            (ID_ALIGN_RIGHT, wx.ITEM_NORMAL, _(u'Right'), '', self.OnAlignRightMenu),
            None,
            (ID_ALIGN_TOP, wx.ITEM_NORMAL, _(u'Top'), '', self.OnAlignTopMenu),
            (ID_ALIGN_MIDDLE, wx.ITEM_NORMAL, _(u'Middle'), '', self.OnAlignMiddleMenu),
            (ID_ALIGN_BOTTOM, wx.ITEM_NORMAL, _(u'Bottom'), '', self.OnAlignBottomMenu)])

    # Add Wire Menu items to the given menu
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def PopupForceMenu(self):
        iec_path = self.GetElementIECPath(self.SelectedElement)
        if iec_path is not None:
            menu = wx.Menu(title='')
            new_id = wx.NewId()
            AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Force value"))
            self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper(), self.SelectedElement), id=new_id)
            new_id = wx.NewId()
            AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Release value"))
            self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), id=new_id)
            if self.SelectedElement.IsForced():
                menu.Enable(new_id, True)
            else:
                menu.Enable(new_id, False)
            if self.Editor.HasCapture():
                self.Editor.ReleaseMouse()
            self.Editor.PopupMenu(menu)
            menu.Destroy()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def PopupWireMenu(self, delete=True):
        menu = wx.Menu(title='')

        # If Check that wire can be replace by connections or abort
        connected = self.SelectedElement.GetConnected()
        start_connector = (
            self.SelectedElement.GetEndConnected()
            if self.SelectedElement.GetStartConnected() in connected
            else self.SelectedElement.GetStartConnected())

        self.AddWireMenuItems(
            menu, delete,
            start_connector.GetDirection() == EAST and
            not isinstance(start_connector.GetParentBlock(), SFC_Step))

        menu.AppendSeparator()
        self.AddDefaultMenuItems(menu, block=True)
        self.Editor.PopupMenu(menu)
        menu.Destroy()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnVariablesGridEditorShown(self, event):
        row, col = event.GetRow(), event.GetCol()
        if self.Table.GetColLabelValue(col, False) == "Type":
            type_menu = wx.Menu(title='')
            base_menu = wx.Menu(title='')
            for base_type in self.Controler.GetBaseTypes():
                new_id = wx.NewId()
                base_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type)
                self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id)
            type_menu.AppendMenu(wx.NewId(), "Base Types", base_menu)
            datatype_menu = wx.Menu(title='')
            for datatype in self.Controler.GetDataTypes():
                new_id = wx.NewId()
                datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
                self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id)
            type_menu.AppendMenu(wx.NewId(), "User Data Types", datatype_menu)
            rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col))

            self.VariablesGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.VariablesGrid.GetColLabelSize())
            type_menu.Destroy()
            event.Veto()
        else:
            event.Skip()
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY,
                          "Panel Switcher Tutorial")

        self.panel_one = PanelOne(self)
        self.panel_two = PanelTwo(self)
        self.panel_two.Hide()

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.panel_one, 1, wx.EXPAND)
        self.sizer.Add(self.panel_two, 1, wx.EXPAND)
        self.SetSizer(self.sizer)


        menubar = wx.MenuBar()
        fileMenu = wx.Menu()
        switch_panels_menu_item = fileMenu.Append(
            wx.ID_ANY,
            "Switch Panels",
            "Some text")
        self.Bind(wx.EVT_MENU, self.onSwitchPanels,
                  switch_panels_menu_item)
        menubar.Append(fileMenu, '&File')
        self.SetMenuBar(menubar)
项目:Netkeeper    作者:1941474711    | 项目源码 | 文件源码
def CreatePopupMenu(self, event=None):
        menu = wx.Menu()
        menu.Append(self.ID_NAME, C_APP_NAME)
        menu.AppendSeparator()
        menu.Append(self.ID_AUTHOR, "????")
        menu.Append(self.ID_EXIT, "??")
        return menu


# ????
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def wxPythonApp():
    import wx
    app = wx.App()
    frame = wx.Frame(None, -1, "wxPython GUI", size=(200,150))
    frame.SetBackgroundColour('white')
    frame.CreateStatusBar()
    menu= wx.Menu()
    menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
    menuBar = wx.MenuBar()
    menuBar.Append(menu,"File") 
    frame.SetMenuBar(menuBar)     
    frame.Show()
    app.MainLoop()
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def createMenu(self):      
        menu= wx.Menu()
        menu.Append(wx.ID_NEW, "New", "Create something new")
        menu.AppendSeparator()
        _exit = menu.Append(wx.ID_EXIT, "Exit", "Exit the GUI")
        self.Bind(wx.EVT_MENU, self.exitGUI, _exit)
        menuBar = wx.MenuBar()
        menuBar.Append(menu, "File")   
        menu1= wx.Menu()    
        menu1.Append(wx.ID_ABOUT, "About", "wxPython GUI")
        menuBar.Append(menu1, "Help")     
        self.SetMenuBar(menuBar)  
    #----------------------------------------------------------
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        parent.CreateStatusBar() 
        menu= wx.Menu()
        menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
        menuBar = wx.MenuBar()
        menuBar.Append(menu, "File") 
        parent.SetMenuBar(menuBar)  
        button = wx.Button(self, label="Print", pos=(0,60))
        self.Bind(wx.EVT_BUTTON, self.writeToSharedQueue, button)
        self.textBox = wx.TextCtrl(self, size=(280,50), style=wx.TE_MULTILINE)   

    #-----------------------------------------------------------------
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def wxPythonApp():
    import wx
    app = wx.App()
    frame = wx.Frame(None, -1, "wxPython GUI", size=(200,150))
    frame.SetBackgroundColour('white')
    frame.CreateStatusBar()
    menu= wx.Menu()
    menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
    menuBar = wx.MenuBar()
    menuBar.Append(menu, "File") 
    frame.SetMenuBar(menuBar)     
    frame.Show()
    app.MainLoop()
项目:nodemcu-pyflasher    作者:marcelstoer    | 项目源码 | 文件源码
def _get_config_file_path(self):
        return wx.StandardPaths.Get().GetUserConfigDir() + "/nodemcu-pyflasher.json"

    # Menu methods
项目:pyqha    作者:mauropalumbo75    | 项目源码 | 文件源码
def __init__(self, title, pos, size):

        # Initialize some flags
        self.IsEtotRead = False

        wx.Frame.__init__(self, None, -1, title, pos, size)                
        panel = wx.Panel(self, -1)
        panel.SetBackgroundColour("White")

        text = wx.TextCtrl(self, wx.ID_ANY, size=size, style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(text, 1, wx.EXPAND)
        self.SetSizer(sizer)
        self.Fit()

        self.Bind(wx.EVT_CLOSE, self.OnQuit)                             
        self.createMenuBar()       
        self.CreateStatusBar()        
        self.SetStatusText("Welcome to pyQHA")

        # Redirect stout to the TextCtrl in the main panel
        self.redir=RedirectText(text)
        sys.stdout=self.redir
        sys.stderr=self.redir

    ############################################################################
    #
    # Menu functions
    #
项目:pyqha    作者:mauropalumbo75    | 项目源码 | 文件源码
def createMenu(self, menuData):
        menu = wx.Menu()
        for eachLabel, eachStatus, eachHandler in menuData:
            if not eachLabel:
                menu.AppendSeparator()
                continue
            menuItem = menu.Append(-1, eachLabel, eachStatus)
            self.Bind(wx.EVT_MENU, eachHandler, menuItem)
        return menu


    ############################################################################
    #
    # Handling methods, rather self explaining
    #
项目:stopgo    作者:notklaatu    | 项目源码 | 文件源码
def CreateMenuBar(self):
        menubar = wx.MenuBar()
        fileMenu = wx.Menu()
        nitem = fileMenu.Append(wx.ID_NEW,  '&New',  'New project' )
        oitem = fileMenu.Append(wx.ID_OPEN, '&Open', 'Open project')
        self.ritem = fileMenu.Append(wx.ID_SAVEAS, '&Render\tCtrl-r', 'Render')
        self.iitem = fileMenu.Append(wx.ID_ANY, '&Import\tCtrl-i', 'Import image directory')
        self.qitem = fileMenu.Append(wx.ID_EXIT, '&Quit', 'Quit application')

        editMenu = wx.Menu()
        self.zitem = editMenu.Append(wx.ID_UNDO, '&Undo\tCtrl-z', 'Undo Delete')
        #yitem = editMenu.Append(wx.ID_REDO, '&Redo', 'Redo')
        self.ditem = editMenu.Append(wx.ID_DELETE, '&Delete\tDelete', 'Delete')
        pitem = editMenu.Append(wx.ID_PREFERENCES, '&Preferences\tCtrl-,', 'Preferences')

        helpMenu = wx.Menu()
        aitem = helpMenu.Append(wx.ID_ABOUT, '&About\tCtrl-?', 'About Stopgo')

        menubar.Append(fileMenu, '&File')
        menubar.Append(editMenu, '&Edit')
        menubar.Append(helpMenu, '&Help')

        self.Bind(wx.EVT_MENU, lambda event, args=(False): self.OpenFile(event,args), oitem)
        self.Bind(wx.EVT_MENU, self.NewFile, nitem)
        self.Bind(wx.EVT_MENU, self.Pref, pitem)
        self.Bind(wx.EVT_MENU, lambda event,args=(False): ingest.Ingest(self),self.iitem)
        self.Bind(wx.EVT_MENU, self.SimpleQuit, self.qitem)
        self.Bind(wx.EVT_CLOSE, self.SimpleQuit, self.qitem)
        self.Bind(wx.EVT_MENU, self.About, aitem)
        self.SetMenuBar(menubar)
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnRightClick(self, event):
        menu = wx.Menu()
        tPopupID0 = wx.NewId()
        tPopupID1 = wx.NewId()
        tPopupID2 = wx.NewId()
        tPopupID3 = wx.NewId()
        tPopupID4 = wx.NewId()
        tPopupID5 = wx.NewId()
        menu.Append(tPopupID2, "Edit")
        menu.Append(tPopupID0, "New")
        menu.Append(tPopupID1, "Copy")
        menu.AppendSeparator()
        menu.Append(tPopupID3, "Delete")
        menu.Append(tPopupID4, "Delete All")
        wx.EVT_MENU(self, tPopupID2, self.OnPopupEdit)
        wx.EVT_MENU(self, tPopupID0, self.OnPopupNew)
        wx.EVT_MENU(self, tPopupID1, self.OnPopupCopy)
        wx.EVT_MENU(self, tPopupID3, self.OnPopupDelete)
        wx.EVT_MENU(self, tPopupID4, self.OnPopupDeleteAll)
        if len(self.itemDataMap) == 0:
            for m in menu.GetMenuItems():
                m.Enable(False)
            m = menu.FindItemById(tPopupID0)
            m.Enable(True)

        self.PopupMenu(menu, wx.Point(self.x, self.y))
        menu.Destroy()
        event.Skip()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnRightClick(self, event):
        menu = wx.Menu()
        tPopupID0 = wx.NewId()
        tPopupID1 = wx.NewId()
        tPopupID2 = wx.NewId()
        tPopupID3 = wx.NewId()
        tPopupID4 = wx.NewId()
        tPopupID5 = wx.NewId()
        menu.Append(tPopupID2, "Edit")
        menu.Append(tPopupID0, "New")
        menu.Append(tPopupID1, "Copy")
        menu.AppendSeparator()
        menu.Append(tPopupID3, "Delete")
        menu.Append(tPopupID4, "Delete All")
        wx.EVT_MENU(self, tPopupID2, self.OnPopupEdit)
        wx.EVT_MENU(self, tPopupID0, self.OnPopupNew)
        wx.EVT_MENU(self, tPopupID1, self.OnPopupCopy)
        wx.EVT_MENU(self, tPopupID3, self.OnPopupDelete)
        wx.EVT_MENU(self, tPopupID4, self.OnPopupDeleteAll)
        if len(self.itemDataMap) == 0:
            for m in menu.GetMenuItems():
                m.Enable(False)
            m = menu.FindItemById(tPopupID0)
            m.Enable(True)

        self.PopupMenu(menu, wx.Point(self.x, self.y))
        menu.Destroy()
        event.Skip()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnRightClick(self, event):
        tsubPopupID1 = 10
        tsubPopupID2 = 11
        tsubPopupID3 = 12
        submenu = wx.Menu()
        submenu.Append(tsubPopupID1, "Read")
        submenu.Append(tsubPopupID2, "Unread")
        submenu.Append(tsubPopupID3, "Deleted")

        wx.EVT_MENU(self, tsubPopupID1, self.OnPopupMarkRead)
        wx.EVT_MENU(self, tsubPopupID2, self.OnPopupMarkUnread)
        wx.EVT_MENU(self, tsubPopupID3, self.OnPopupMarkDeleted)

        menu = wx.Menu()
        tPopupID0 = wx.NewId()
        tPopupID1 = wx.NewId()
        tPopupID2 = wx.NewId()
        tPopupID3 = wx.NewId()
        tPopupID4 = wx.NewId()
        tPopupID5 = wx.NewId()
        menu.AppendMenu(tPopupID1, "Mark as", submenu)
        menu.AppendSeparator()
        menu.Append(tPopupID2, "Edit")
        menu.Append(tPopupID0, "New")
        menu.Append(tPopupID1, "Copy")
        menu.AppendSeparator()
        menu.Append(tPopupID3, "Delete")
        menu.Append(tPopupID4, "Delete All")

        wx.EVT_MENU(self, tPopupID2, self.OnPopupEdit)
        wx.EVT_MENU(self, tPopupID0, self.OnPopupNew)
        wx.EVT_MENU(self, tPopupID1, self.OnPopupCopy)
        wx.EVT_MENU(self, tPopupID3, self.OnPopupDelete)
        wx.EVT_MENU(self, tPopupID4, self.OnPopupDeleteAll)
        self.PopupMenu(menu, wx.Point(self.x, self.y))
        menu.Destroy()
        event.Skip()
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def init_popup_menu(self):
        self.popup_menu_needs_rebuild = False
        if self.popup_menu is not None:
            self.popup_menu.Destroy()
        menu = wx.Menu()
        menu.Append(wx.NewId(), 'Cursor mode:').Enable(False)
        self.cursor_mode_to_eventID = {}
        cmd_num = 1
        for cursor_mode in self.popup_menu_cursor_modes:
            fxn = self.available_cursor_modes[cursor_mode]['set-to-mode']
            wx_id = wx.NewId()
            menu.AppendCheckItem(wx_id, '   ' + cursor_mode + '\tCtrl+' + str(cmd_num))
            wx.EVT_MENU(menu, wx_id, fxn)
            self.cursor_mode_to_eventID[cursor_mode] = wx_id
            self.Bind(wx.EVT_MENU, fxn, id=wx_id)
            self.accelerator_table.append((wx.ACCEL_CMD, ord(str(cmd_num)), wx_id))
            cmd_num += 1
        menu.AppendSeparator()
        image_cmap_submenu = wx.Menu()
        for cmap in self.ztv_frame.available_cmaps:
            menu_item = image_cmap_submenu.AppendCheckItem(self.cmap_to_eventID[cmap], cmap)
            wx.EVT_MENU(image_cmap_submenu, self.cmap_to_eventID[cmap], self.on_change_cmap_event)
            menu_item.SetBitmap(self.cmap_bitmaps[cmap])
        menu.AppendMenu(-1, 'Color Maps', image_cmap_submenu)
        wx_id = wx.NewId()
        self.menu_item_invert_map = menu.AppendCheckItem(wx_id, 'Invert Color Map')
        wx.EVT_MENU(menu, wx_id, self.ztv_frame.invert_cmap)
        self.menu_item_invert_map.Check(self.ztv_frame.is_cmap_inverted)
        image_scaling_submenu = wx.Menu()
        for scaling in self.ztv_frame.available_scalings:
            menu_item = image_scaling_submenu.AppendCheckItem(self.scaling_to_eventID[scaling], scaling)
            wx.EVT_MENU(image_scaling_submenu, self.scaling_to_eventID[scaling], self.on_change_scaling_event)
        menu.AppendMenu(-1, 'Scaling', image_scaling_submenu)
        menu.AppendSeparator()
        self.popup_menu_cur_fits_header_eventID = wx.NewId()
        self._append_menu_item(menu, self.popup_menu_cur_fits_header_eventID, 'FITS Header',
                               self.on_display_cur_fits_header)
        self.popup_menu = menu
        self.SetAcceleratorTable(wx.AcceleratorTable(self.accelerator_table))
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def init_popup_menu(self):
        self.popup_menu_needs_rebuild = False
        if self.popup_menu is not None:
            self.popup_menu.Destroy()
        menu = wx.Menu()
        menu.Append(wx.NewId(), 'Cursor mode:').Enable(False)
        self.cursor_mode_to_eventID = {}
        cmd_num = 1
        for cursor_mode in self.popup_menu_cursor_modes:
            fxn = self.available_cursor_modes[cursor_mode]['set-to-mode']
            wx_id = wx.NewId()
            menu.AppendCheckItem(wx_id, '   ' + cursor_mode + '\tCtrl+' + str(cmd_num))
            wx.EVT_MENU(menu, wx_id, fxn)
            self.cursor_mode_to_eventID[cursor_mode] = wx_id
            self.Bind(wx.EVT_MENU, fxn, id=wx_id)
            self.accelerator_table.append((wx.ACCEL_CMD, ord(str(cmd_num)), wx_id))
            cmd_num += 1
        menu.AppendSeparator()
        image_cmap_submenu = wx.Menu()
        for cmap in self.ztv_frame.available_cmaps:
            menu_item = image_cmap_submenu.AppendCheckItem(self.cmap_to_eventID[cmap], cmap)
            wx.EVT_MENU(image_cmap_submenu, self.cmap_to_eventID[cmap], self.on_change_cmap_event)
            menu_item.SetBitmap(self.cmap_bitmaps[cmap])
        menu.AppendMenu(-1, 'Color Maps', image_cmap_submenu)
        wx_id = wx.NewId()
        self.menu_item_invert_map = menu.AppendCheckItem(wx_id, 'Invert Color Map')
        wx.EVT_MENU(menu, wx_id, self.ztv_frame.invert_cmap)
        self.menu_item_invert_map.Check(self.ztv_frame.is_cmap_inverted)
        image_scaling_submenu = wx.Menu()
        for scaling in self.ztv_frame.available_scalings:
            menu_item = image_scaling_submenu.AppendCheckItem(self.scaling_to_eventID[scaling], scaling)
            wx.EVT_MENU(image_scaling_submenu, self.scaling_to_eventID[scaling], self.on_change_scaling_event)
        menu.AppendMenu(-1, 'Scaling', image_scaling_submenu)
        menu.AppendSeparator()
        self.popup_menu_cur_fits_header_eventID = wx.NewId()
        self._append_menu_item(menu, self.popup_menu_cur_fits_header_eventID, 'FITS Header',
                               self.on_display_cur_fits_header)
        self.popup_menu = menu
        self.SetAcceleratorTable(wx.AcceleratorTable(self.accelerator_table))
项目:PancakeViewer    作者:forensicmatt    | 项目源码 | 文件源码
def _InitRecordPaneMenu(self):
        # make a menu
        self.record_pane_menu = wx.Menu()

        # Create IDs #
        self.record_pane_popup_id1 = wx.NewId()

        # Create Binds #
        self.Bind(wx.EVT_MENU, self.RecordPaneMenu_ExtractClick, id=self.record_pane_popup_id1)

        # Create Items #
        self.record_pane_menu.Append(self.record_pane_popup_id1, "Extract")
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def OnRightDown(self,event):
        if IsNotWX4():
            item = self.mainlist.HitTest(event.GetPosition())[0]
        else:
            item = self.mainlist.HitTest(event.GetPoint())[0]
        if item > -1:
            menu = wx.Menu()
            if IsNotWX4():
                self.CurrentListItem = event.m_itemIndex
            else:
                self.CurrentListItem = event.GetIndex()
            itemup = wx.MenuItem(menu, wx.ID_UP, "Move up")
            itemdel = wx.MenuItem(menu, wx.ID_DELETE, "Delete")
            itemdown = wx.MenuItem(menu, wx.ID_DOWN, "Move Down")
            if IsNotWX4():
                menu.AppendItem(itemup)
                menu.AppendItem(itemdel)
                menu.AppendItem(itemdown)
            else:
                menu.Append(itemup)
                menu.Append(itemdel)
                menu.Append(itemdown)
            self.Bind(wx.EVT_MENU, self.OnClickUp, itemup)
            self.Bind(wx.EVT_MENU, self.OnItemDel, itemdel)
            self.Bind(wx.EVT_MENU, self.OnClickDown, itemdown)
            if IsNotWX4():
                x,y = event.GetPosition()
            else:
                x,y = event.GetPoint().Get()
            mx,my = self.hbox1.GetSize()
            x= 3*mx/4
            self.PopupMenu( menu, (x,y))
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, parent, title):
        self.dirname=os.getcwd()
        wx.Frame.__init__(self, parent, title=title, size=(1000,700))
        self.SetSizeHints(1000,700,-1,-1)
        self.CreateStatusBar()
        filemenu= wx.Menu()
        menuOpen = filemenu.Append(wx.ID_OPEN, "&Open"," Open saved state")
        menuSave = filemenu.Append(wx.ID_SAVE, "&Save"," Save current state")
        filemenu.InsertSeparator(2)
        menuNew = filemenu.Append(wx.ID_NEW, "&New"," Create new session")
        filemenu.InsertSeparator(4)
        menuExit = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")
        viewmenu = wx.Menu()
        vismenu = wx.Menu()
        self.viewmenuundock = vismenu.Append(wx.ID_ANY,"&Undock","Undock the visualisation")
        self.viewmenuundock.Enable(0)
        self.viewmenudock = vismenu.Append(wx.ID_ANY,"&Dock","Dock the visualisation")
        self.viewmenudock.Enable(0)
        self.Bind(wx.EVT_MENU, self.OnUndock, self.viewmenuundock)
        self.Bind(wx.EVT_MENU, self.OnDock, self.viewmenudock)
        if IsNotWX4():
            viewmenu.AppendMenu(wx.ID_ANY,"&Visualisation", vismenu)
        else:
            viewmenu.Append(wx.ID_ANY,"&Visualisation", vismenu)
        self.visualdialog_docked = True
        editmenu = wx.Menu()
        self.menuCWD = editmenu.Append(wx.ID_ANY, "Current Working &Directory","Current Working Directory")
        self.Bind(wx.EVT_MENU, self.OnCWD, self.menuCWD)
        helpmenu= wx.Menu()
        menuAbout= helpmenu.Append(wx.ID_ABOUT, "&About"," Information about Bonsu")
        menuDoc= helpmenu.Append(wx.ID_HELP, "&Contents","Documentation")
        menuBar = wx.MenuBar()
        menuBar.Append(filemenu,"&File")
        menuBar.Append(viewmenu,"&View")
        menuBar.Append(editmenu,"&Edit")
        menuBar.Append(helpmenu,"&Help")
        self.SetMenuBar(menuBar)
        self.Bind(wx.EVT_MENU, self.OnOpen, menuOpen)
        self.Bind(wx.EVT_MENU, self.OnSave, menuSave)
        self.Bind(wx.EVT_MENU, self.OnNew, menuNew)
        self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
        self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
        self.Bind(wx.EVT_MENU, self.OnHelp, menuDoc)
        self.Bind(wx.EVT_CLOSE, self.OnExit)
        self.fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize()
        self.font = wx.Font(self.fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        self.SetFont(self.font)
        icon = wx.Icon(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'image',  'bonsu.ico'), wx.BITMAP_TYPE_ICO)
        wx.Frame.SetIcon(self, icon)
        self.nb = None
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.Fit()
        self.Layout()
        self.Show()
项目:JincinExamHelper    作者:Qinet    | 项目源码 | 文件源码
def __init__(self, parent, title):
        (self.display_length_, self.display_height_) = wx.GetDisplaySize()
        self.frame_width_ = self.display_length_ * 90 / 100
        self.frame_height_ = self.display_height_ * 90 / 100
        self.answer_panel_width_ = self.frame_width_ * 15 / 100
        super(MainFrame, self).__init__(parent=parent, title=title, size=(self.frame_width_, self.frame_height_))

        self.splitter = wx.SplitterWindow(parent=self, style=wx.SP_LIVE_UPDATE)
        self.splitter.SetMinimumPaneSize(min=100)

        self.web_panel = WebPanel(parent=self.splitter)
        self.answer_panel = wx.Panel(parent=self.splitter)
        self.answers_box = wx.BoxSizer(orient=wx.VERTICAL)
        self.answers_box.Add(item=self.answer_panel)

        self.splitter.SplitVertically(window1=self.answer_panel, window2=self.web_panel,
                                      sashPosition=self.answer_panel_width_)

        self.Sizer = wx.BoxSizer(orient=wx.VERTICAL)
        self.Sizer.Add(item=self.splitter, proportion=CAN_CHANGE, flag=wx.EXPAND)

        auto_answer_button = wx.Button(parent=self, label=u"????")
        self.Bind(event=wx.EVT_BUTTON, handler=self.click_search_answer, source=auto_answer_button)

        self.buttons_box = wx.BoxSizer(orient=wx.HORIZONTAL)
        self.buttons_box.Add(item=auto_answer_button, proportion=CAN_NOT_CHANGE, flag=wx.LEFT | wx.RIGHT, border=5)

        self.Sizer.Add(item=self.buttons_box, proportion=CAN_NOT_CHANGE, flag=wx.TOP | wx.BOTTOM, border=5)

        menu = wx.Menu()
        menu_about = menu.Append(id=wx.ID_ABOUT, text=u"&??", help=u" ?????")
        menu_feedback = menu.Append(id=wx.ID_OPEN, text=u"&??", help=u" ??")
        self.Bind(event=wx.EVT_MENU, handler=self.show_about, source=menu_about)
        self.Bind(event=wx.EVT_MENU, handler=self.show_feedback, source=menu_feedback)
        menu_bar = wx.MenuBar()
        menu_bar.Append(menu, u"&??")
        self.SetMenuBar(menu_bar)
        self.statusbar = self.CreateStatusBar()
        self.Centre()
项目:Supplicant    作者:mayuko2012    | 项目源码 | 文件源码
def __init__(self, title, pos, size):

        self.threads = []
        self.getsession = []
        self.MAC=''
        self.IP=''
        wx.Frame.__init__(self, None, -1, title, pos, size)
        menuFile = wx.Menu()
        menuFile.Append(1, u"&??...",u"?????")
        menuFile.Append(3,u"&????",u"?????IP")
        menuFile.AppendSeparator() 
        menuFile.Append(2,u"&Bug Report",u"???????bug?")
        menuBar = wx.MenuBar()
        menuBar.Append(menuFile, u"&??")
        self.SetMenuBar(menuBar)
        self.Bind(wx.EVT_MENU, self.OnAbout,id=1)
        self.Bind(wx.EVT_MENU,self.OnBugReport,id=2)
        hosts = self.Bind(wx.EVT_MENU,self.OnSet,id=3)
        self.CreateStatusBar() 

        self.SetStatusText(u"????")

        panel = wx.Panel(self) 
        self.connect = wx.Button(panel,label=u"??",pos=(240, 60),size=(80, 50)) 
        self.disconnect = wx.Button(panel,label=u"??",pos=(330,60),size=(80,50))
        self.connect.Disable()
        self.disconnect.Disable()
        self.Bind(wx.EVT_BUTTON, self.OnDisconnect,self.disconnect)
        self.Bind(wx.EVT_BUTTON,self.OnConnect,self.connect)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)         
        wx.StaticText(panel, -1, u"???:", pos=(28, 40))
        self.username = wx.TextCtrl(panel, -1 ,pos=(80, 40))
        self.username.SetInsertionPoint(0)
        self.Bind(wx.EVT_TEXT,self.Onuser,self.username)
        wx.StaticText(panel,-1,u"??:",pos=(242,40))
        self.pwd = wx.TextCtrl(panel, -1,pos=(280,40),style=wx.TE_PASSWORD |wx.TE_PROCESS_ENTER)
        self.Bind(wx.EVT_TEXT,self.Onpwd,self.pwd)
        wx.CheckBox(panel, -1, u"????", (20, 80), (150, 20))
        wx.CheckBox(panel, -1, u"????", (110, 80), (150, 20))
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
def search_menu(self):
        menu = wx.Menu()
        menu.Append(wx.ID_ANY, "Recent searches").Enable(False)
        for item in self.search_recent:
            self.Bind(wx.EVT_MENU, handler=self.click_recent, source=menu.Append(wx.ID_ANY, item))
        return menu
项目:pyDataView    作者:edwardsmith999    | 项目源码 | 文件源码
def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, -1, title, size=(550, 350))
        self.SetBackgroundColour(wx.NamedColour("WHITE"))

        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        self.change_plot(0)

        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.add_buttonbar()
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.add_toolbar()  # comment this out for no toolbar

        menuBar = wx.MenuBar()

        # File Menu
        menu = wx.Menu()
        menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")
        menuBar.Append(menu, "&File")

        if IS_GTK or IS_WIN:
            # Equation Menu
            menu = wx.Menu()
            for i, (mt, func) in enumerate(functions):
                bm = mathtext_to_wxbitmap(mt)
                item = wx.MenuItem(menu, 1000 + i, "")
                item.SetBitmap(bm)
                menu.AppendItem(item)
                self.Bind(wx.EVT_MENU, self.OnChangePlot, item)
            menuBar.Append(menu, "&Functions")

        self.SetMenuBar(menuBar)

        self.SetSizer(self.sizer)
        self.Fit()
项目:wpkg-gp-client    作者:sonicnkt    | 项目源码 | 文件源码
def CreatePopupMenu(self):
        menu = wx.Menu()
        if update_method:
            create_menu_item(menu, _(u"Check for updates"), "update", self.manual_timer)
        create_menu_item(menu, _(u"System update"), "upgrade", self.on_upgrade)
        menu.AppendSeparator()
        create_menu_item(menu, _(u"Help"), "help", self.on_about)
        if self.shutdown_scheduled:
            menu.AppendSeparator()
            create_menu_item(menu, _(u"Cancel shutdown"), "cancel", self.on_cancleshutdown)
        if allow_quit:
            menu.AppendSeparator()
            create_menu_item(menu, _(u"Close"), "quit", self.on_exit)
        return menu
项目:wpkg-gp-client    作者:sonicnkt    | 项目源码 | 文件源码
def CreatePopupMenu(self):
        menu = wx.Menu()
        if update_method:
            create_menu_item(menu, _(u"Check for updates"), "update", self.manual_timer)
        create_menu_item(menu, _(u"System update"), "upgrade", self.on_upgrade)
        menu.AppendSeparator()
        create_menu_item(menu, _(u"Help"), "help", self.on_about)
        if self.shutdown_scheduled:
            menu.AppendSeparator()
            create_menu_item(menu, _(u"Cancel shutdown"), "cancel", self.on_cancleshutdown)
        if allow_quit:
            menu.AppendSeparator()
            create_menu_item(menu, _(u"Close"), "quit", self.on_exit)
        return menu
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def _init_coll_DisplayMenu_Items(self, parent):
        AppendMenu(parent, help='', id=wx.ID_REFRESH,
                   kind=wx.ITEM_NORMAL, text=_(u'Refresh') + '\tCTRL+R')
        if self.EnableDebug:
            AppendMenu(parent, help='', id=wx.ID_CLEAR,
                       kind=wx.ITEM_NORMAL, text=_(u'Clear Errors') + '\tCTRL+K')
        parent.AppendSeparator()
        zoommenu = wx.Menu(title='')
        parent.AppendMenu(wx.ID_ZOOM_FIT, _("Zoom"), zoommenu)
        for idx, value in enumerate(ZOOM_FACTORS):
            new_id = wx.NewId()
            AppendMenu(zoommenu, help='', id=new_id,
                       kind=wx.ITEM_RADIO, text=str(int(round(value * 100))) + "%")
            self.Bind(wx.EVT_MENU, self.GenerateZoomFunction(idx), id=new_id)

        parent.AppendSeparator()
        AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE,
                   kind=wx.ITEM_NORMAL, text=_(u'Switch perspective') + '\tF12')
        self.Bind(wx.EVT_MENU, self.SwitchFullScrMode, id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE)

        AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE,
                   kind=wx.ITEM_NORMAL, text=_(u'Reset Perspective'))
        self.Bind(wx.EVT_MENU, self.OnResetPerspective, id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE)

        self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH)
        if self.EnableDebug:
            self.Bind(wx.EVT_MENU, self.OnClearErrorsMenu, id=wx.ID_CLEAR)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def _init_utils(self):
        self.MenuBar = wx.MenuBar()

        self.FileMenu = wx.Menu(title='')
        self.EditMenu = wx.Menu(title='')
        self.DisplayMenu = wx.Menu(title='')
        self.HelpMenu = wx.Menu(title='')

        self._init_coll_MenuBar_Menus(self.MenuBar)
        self._init_coll_FileMenu_Items(self.FileMenu)
        self._init_coll_EditMenu_Items(self.EditMenu)
        self._init_coll_DisplayMenu_Items(self.DisplayMenu)
        self._init_coll_HelpMenu_Items(self.HelpMenu)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnQuitMenu(self, event):
        self.Close()

    # -------------------------------------------------------------------------------
    #                            Edit Menu Functions
    # -------------------------------------------------------------------------------
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnSearchInProjectMenu(self, event):
        dialog = SearchInProjectDialog(self)
        if dialog.ShowModal() == wx.ID_OK:
            criteria = dialog.GetCriteria()
            if len(criteria) > 0:
                result = self.Controler.SearchInProject(criteria)
                self.ClearSearchResults()
                self.SearchResultPanel.SetSearchResults(criteria, result)
                self.SelectTab(self.SearchResultPanel)

    # -------------------------------------------------------------------------------
    #                             Display Menu Functions
    # -------------------------------------------------------------------------------
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def BuildStdIECTypesMenu(self, type_menu):
            # build a submenu containing standard IEC types
            base_menu = wx.Menu(title='')
            for base_type in self.Controler.GetBaseTypes():
                new_id = wx.NewId()
                base_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type)
                self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id)

            type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def BuildUserTypesMenu(self, type_menu):
            # build a submenu containing user-defined types
            datatype_menu = wx.Menu(title='')
            datatypes = self.Controler.GetDataTypes(basetypes=False, confnodetypes=False)
            for datatype in datatypes:
                new_id = wx.NewId()
                datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
                self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id)

            type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def BuildLibsTypesMenu(self, type_menu):
        for category in self.Controler.GetConfNodeDataTypes():
            if len(category["list"]) > 0:
                # build a submenu containing confnode types
                confnode_datatype_menu = wx.Menu(title='')
                for datatype in category["list"]:
                    new_id = wx.NewId()
                    confnode_datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
                    self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id)

                type_menu.AppendMenu(wx.NewId(), category["name"], confnode_datatype_menu)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def BuildProjectTypesMenu(self, type_menu, classtype):
        # build a submenu containing function block types
        bodytype = self.Controler.GetEditedElementBodyType(self.TagName)
        pouname, poutype = self.Controler.GetEditedElementType(self.TagName)
        if classtype in ["Input", "Output", "InOut", "External", "Global"] or \
           poutype != "function" and bodytype in ["ST", "IL"]:
            functionblock_menu = wx.Menu(title='')
            fbtypes = self.Controler.GetFunctionBlockTypes(self.TagName)
            for functionblock_type in fbtypes:
                new_id = wx.NewId()
                functionblock_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type)
                self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id)

            type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu)