python类Menu()的实例源码

Control_Frameworks.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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())
Main.py 文件源码 项目:nodemcu-pyflasher 作者: marcelstoer 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)
wxPython_Wallpaper.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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()
wxPython_OpenGL_GUI.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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()
import_OpenGL_cube_and_cone.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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
pySIMlastnum.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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)
pySIMphonebook.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
UploaderApp.py 文件源码 项目:irida-miseq-uploader 作者: phac-nml 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
source_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
color_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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
source_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
IDEFrame.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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
    # -------------------------------------------------------------------------------
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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)
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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()
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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()
CodeFileEditor.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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()
main.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
taskicon.py 文件源码 项目:Netkeeper 作者: 1941474711 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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


# ????
Control_Frameworks_NOT_working.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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()
GUI_wxPython.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)  
    #----------------------------------------------------------
Communicate.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
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)   

    #-----------------------------------------------------------------
Embed_wxPython.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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()
Main.py 文件源码 项目:nodemcu-pyflasher 作者: marcelstoer 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _get_config_file_path(self):
        return wx.StandardPaths.Get().GetUserConfigDir() + "/nodemcu-pyflasher.json"

    # Menu methods
pyqhaGUI.py 文件源码 项目:pyqha 作者: mauropalumbo75 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
    #
pyqhaGUI.py 文件源码 项目:pyqha 作者: mauropalumbo75 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
    #
gui.py 文件源码 项目:stopgo 作者: notklaatu 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
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)
pySIMlastnum.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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()
pySIMphonebook.py 文件源码 项目:SIMreader 作者: stoic1979 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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()


问题


面经


文章

微信
公众号

扫码关注公众号