当前位置: 首页>>代码示例>>Python>>正文


Python Tkinter.Menu方法代码示例

本文整理汇总了Python中Tkinter.Menu方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.Menu方法的具体用法?Python Tkinter.Menu怎么用?Python Tkinter.Menu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tkinter的用法示例。


在下文中一共展示了Tkinter.Menu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: menubar

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def menubar(self):
        menubar = tk.Menu(self.master)
        
        # File
        filemenu = tk.Menu(menubar, tearoff = 0)
        filemenu.add_command(label = "Export models", command = self.export_models)
        filemenu.add_command(label = "Export fitness", command = self.export_fitness)
        filemenu.add_separator()
        filemenu.add_command(label = "Exit", command = self.close_window)
        
        # Help
        helpmenu = tk.Menu(menubar, tearoff = 0)
        helpmenu.add_command(label = "About", command = self.about)
        
        # Display menu bar
        menubar.add_cascade(label = "File", menu = filemenu)
        menubar.add_cascade(label = "Help", menu = helpmenu)
        self.master.config(menu = menubar) 
开发者ID:keurfonluu,项目名称:stochopy,代码行数:20,代码来源:gui.py

示例2: drawtext

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def drawtext(self):
            """Override drawtext from _TreeWidget.TreeNode.

            This seems to be a good place to add the popup menu.

            """
            _TreeWidget.TreeNode.drawtext(self)
            # create a menu
            menu = _Tkinter.Menu(self.canvas, tearoff=0)
            menu.add_command(label="reload referrers", command=self.reload_referrers)
            menu.add_command(label="print", command=self.print_object)
            menu.add_separator()
            menu.add_command(label="expand", command=self.expand)
            menu.add_separator()
            # the popup only disappears when to click on it
            menu.add_command(label="Close Popup Menu")
            def do_popup(event):
                menu.post(event.x_root, event.y_root)
            self.label.bind("<Button-3>", do_popup)
            # override, i.e. disable the editing of items

            # disable editing of TreeNodes
            def edit(self, event=None): pass #PYCHOK see comment above
            def edit_finish(self, event=None): pass #PYCHOK see comment above
            def edit_cancel(self, event=None): pass #PYCHOK see comment above 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:27,代码来源:refbrowser.py

示例3: _build_menu

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def _build_menu(self):
        self.menubar = tk.Menu(self)
        self.config(menu=self.menubar)

        view = tk.Menu(self.menubar, tearoff=0)
        view.add_command(label='Undo', command=self.canvas.undo, accelerator="Ctrl+Z")
        self.bind_all("<Control-z>", lambda e: self.canvas.undo())  # Implement accelerator
        view.add_command(label='Redo', command=self.canvas.redo)
        view.add_separator()
        view.add_command(label='Center on node...', command=self.center_on_node)
        view.add_separator()
        view.add_command(label='Reset Node Marks', command=self.reset_node_markings)
        view.add_command(label='Reset Edge Marks', command=self.reset_edge_markings)
        view.add_command(label='Redraw Plot', command=self.canvas.replot)
        view.add_separator()
        view.add_command(label='Grow display one level...', command=self.grow_all)

        self.menubar.add_cascade(label='View', menu=view) 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:20,代码来源:viewer.py

示例4: _init_menubar

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def _init_menubar(self):
        menubar = Menu(self._top)

        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label='Print to Postscript', underline=0,
                             command=self._cframe.print_to_file,
                             accelerator='Ctrl-p')
        filemenu.add_command(label='Exit', underline=1,
                             command=self.destroy, accelerator='Ctrl-x')
        menubar.add_cascade(label='File', underline=0, menu=filemenu)

        zoommenu = Menu(menubar, tearoff=0)
        zoommenu.add_radiobutton(label='Tiny', variable=self._size,
                                 underline=0, value=10, command=self.resize)
        zoommenu.add_radiobutton(label='Small', variable=self._size,
                                 underline=0, value=12, command=self.resize)
        zoommenu.add_radiobutton(label='Medium', variable=self._size,
                                 underline=0, value=14, command=self.resize)
        zoommenu.add_radiobutton(label='Large', variable=self._size,
                                 underline=0, value=28, command=self.resize)
        zoommenu.add_radiobutton(label='Huge', variable=self._size,
                                 underline=0, value=50, command=self.resize)
        menubar.add_cascade(label='Zoom', underline=0, menu=zoommenu)

        self._top.config(menu=menubar) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:27,代码来源:tree.py

示例5: __init__

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def __init__(self, master):
        tk.Frame.__init__(self, master)
        self.pack()
        self.master.title("Hello World")
        self.master.resizable(False, False)
        self.master.tk_setPalette(background='#ececec')

        x = (self.master.winfo_screenwidth() - self.master.winfo_reqwidth()) / 2
        y = (self.master.winfo_screenheight() - self.master.winfo_reqheight()) / 3
        self.master.geometry("+{}+{}".format(x, y))

        self.master.config(menu=tk.Menu(self.master))

        dialog_frame = tk.Frame(self)
        dialog_frame.pack(padx=20, pady=15)

        tk.Label(dialog_frame, text="This is your first GUI. (highfive)").pack()

        button_frame = tk.Frame(self)
        button_frame.pack(padx=15, pady=(0, 15), anchor='e')

        tk.Button(button_frame, text='OK', default='active', command=self.click_ok).pack(side='right')

        tk.Button(button_frame, text='Cancel', command=self.click_cancel).pack(side='right') 
开发者ID:brysontyrrell,项目名称:MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter,代码行数:26,代码来源:03_Organizing_with_Frames.py

示例6: __menu

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def __menu (self) :
		menubar = Tkinter.Menu(self.master)

		fileMenu = Tkinter.Menu(menubar, tearoff = 0)
		fileMenu.add_command(label = "Config", command = self.__configPanel)
		fileMenu.add_command(label = "Close", command = self.master.quit)
		menubar.add_cascade(label = "File", menu = fileMenu)

		aboutMenu = Tkinter.Menu(menubar, tearoff = 0)
		aboutMenu.add_command(label = "Info", command = self.__showInfo)
		aboutMenu.add_command(label = "Check Update", command = self.__chkUpdate)
		menubar.add_cascade(label = "About", menu = aboutMenu)

		helpMenu = Tkinter.Menu(menubar, tearoff = 0)
		helpMenu.add_command(label = "GitHub", command = lambda target = self.gitUrl : webbrowser.open_new(target))
		helpMenu.add_command(label = "Release Notes", command = lambda target = self.appUrl : webbrowser.open_new(target))
		helpMenu.add_command(label = "Send Feedback", command = lambda target = self.feedUrl : webbrowser.open_new(target))
		menubar.add_cascade(label = "Help", menu = helpMenu)

		self.master.config(menu = menubar) 
开发者ID:EvilCult,项目名称:Video-Downloader,代码行数:22,代码来源:guiClass.py

示例7: __init__

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def __init__(self, master, create, callback, items):
        Tkinter.Menu.__init__(self, master)

        cmdMenu = Tkinter.Menu(self)
        self.add_cascade(label="Actions", menu=cmdMenu)
        
        cmdMenu.add_command(label='Create', command=create)
        cmdMenu.add_separator()
        cmdMenu.add_command(label='Quit', command=reactor.crash)

        tapMenu = Tkinter.Menu(self)
        self.add_cascade(label="Applications", menu=tapMenu)

        for item in items:
            tapMenu.add_command(
                label=item, command=lambda i=item, c = callback: c(i)
            ) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:19,代码来源:tkmktap.py

示例8: initialize_menu

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def initialize_menu(self):
        """
        Initialize the menu at the top
        """
        self.menubar = Tkinter.Menu(self,relief="flat")
        filemenu = Tkinter.Menu(self.menubar,tearoff=0)
        filemenu.add_command(label="About",command=self.AboutScoary)
        filemenu.add_separator()
        filemenu.add_command(label="Quit",command=self.quit)
        self.filemenu = filemenu
        self.menubar.add_cascade(label="File",menu=self.filemenu)
        
        optsmenu = Tkinter.Menu(self.menubar,tearoff=0)
        optsmenu.add_command(label="Clear", command=self.ClearAll)
        optsmenu.add_command(label="Test example",
                             command=self.TestExample)
        self.optsmenu = optsmenu
        self.menubar.add_cascade(label="Options",menu=self.optsmenu)
        
        self.config(menu=self.menubar) 
开发者ID:AdmiralenOla,项目名称:Scoary,代码行数:22,代码来源:GUI.py

示例9: onTokenRightClick

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def onTokenRightClick(self, event):
        item = self._get_id(event)

        popup = tk.Menu(self, tearoff=0)
        popup.add_command(label='Grow', command=lambda: self.grow_node(item),
                              accelerator='G')
        popup.add_command(label='Grow until...',
                          command=lambda: self.grow_until(item))
        popup.add_command(label='Mark', command=lambda: self.mark_node(item),
                              accelerator='M')
        popup.add_command(label='Hide', command=lambda: self.hide_node(item),
                              accelerator='H')

        hide_behind = tk.Menu(popup, tearoff=0)
        for _, n in self.dispG.edges_iter(item):
            assert _ == item
            if self._radial_behind(item, n):
                state = tk.ACTIVE
            else:
                state = tk.DISABLED
            hide_behind.add_command(label=str(self.dispG.node[n]['dataG_id']),
                  state=state,
                  command=lambda item=item, n=n: self.hide_behind(item, n))

        popup.add_cascade(label='Hide Behind', menu=hide_behind)

        token = self.dispG.node[item]['token']
        token.customize_menu(popup, item)

        try:
            popup.post(event.x_root, event.y_root)
        finally:
            popup.grab_release() 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:35,代码来源:graph_canvas.py

示例10: onEdgeRightClick

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def onEdgeRightClick(self, event):
        item = self._get_id(event, 'edge')
        for u,v,k,d in self.dispG.edges_iter(keys=True, data=True):
            if d['token'].id == item:
                break

        popup = tk.Menu(self, tearoff=0)
        popup.add_command(label='Mark', command=lambda: self.mark_edge(u,v,k))
        d['token'].customize_menu(popup)

        try:
            popup.post(event.x_root, event.y_root)
        finally:
            popup.grab_release() 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:16,代码来源:graph_canvas.py

示例11: _init_menubar

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def _init_menubar(self, root):
        menubar = Tkinter.Menu(root)

        # File menu
        filemenu = Tkinter.Menu(menubar, tearoff=0)
        filemenu.add_command(label='Load Chart', accelerator='Ctrl-o',
                             underline=0, command=self.load_chart_dialog)
        filemenu.add_command(label='Save Output', accelerator='Ctrl-s',
                             underline=0, command=self.save_chart_dialog)
        filemenu.add_separator()
        filemenu.add_command(label='Exit', underline=1,
                             command=self.destroy, accelerator='Ctrl-x')
        menubar.add_cascade(label='File', underline=0, menu=filemenu)

        # Compare menu
        opmenu = Tkinter.Menu(menubar, tearoff=0)
        opmenu.add_command(label='Intersection',
                           command=self._intersection,
                           accelerator='+')
        opmenu.add_command(label='Union',
                           command=self._union,
                           accelerator='*')
        opmenu.add_command(label='Difference',
                           command=self._difference,
                           accelerator='-')
        opmenu.add_separator()
        opmenu.add_command(label='Swap Charts',
                           command=self._swapcharts)
        menubar.add_cascade(label='Compare', underline=0, menu=opmenu)

        # Add the menu
        self._root.config(menu=menubar) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:34,代码来源:chart.py

示例12: about

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def about(self, *e):
        ABOUT = ("NLTK Chart Parser Demo\n"+
                 "Written by Edward Loper")
        tkMessageBox.showinfo('About: Chart Parser Demo', ABOUT)

    #////////////////////////////////////////////////////////////
    # File Menu
    #//////////////////////////////////////////////////////////// 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:10,代码来源:chart.py

示例13: set_sentence

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def set_sentence(self, sentence):
        self._tokens = list(tokenize.whitespace(sentence))
        self.reset()

    #////////////////////////////////////////////////////////////
    # View Menu
    #//////////////////////////////////////////////////////////// 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:9,代码来源:chart.py

示例14: view_results

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def view_results(self, *e):
        if self._results is not None: self._results.destroy()
        self._results = ChartResultsView(self._root, self._chart,
                                         self._grammar)

    #////////////////////////////////////////////////////////////
    # Zoom Menu
    #//////////////////////////////////////////////////////////// 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:10,代码来源:chart.py

示例15: _init_menubar

# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Menu [as 别名]
def _init_menubar(self, parent):
        menubar = Tkinter.Menu(parent)

        filemenu = Tkinter.Menu(menubar, tearoff=0)
        filemenu.add_command(label='Print to Postscript', underline=0,
                             command=self.postscript, accelerator='Ctrl-p')
        filemenu.add_command(label='Exit', underline=1,
                             command=self.destroy, accelerator='Ctrl-x')
        menubar.add_cascade(label='File', underline=0, menu=filemenu)

        zoommenu = Tkinter.Menu(menubar, tearoff=0)
        zoommenu.add_command(label='Zoom in', underline=5,
                             command=self._zoom_in, accelerator='left click')
        zoommenu.add_command(label='Zoom out', underline=5,
                             command=self._zoom_out, accelerator='right click')
        zoommenu.add_command(label='View 100%', command=self._zoom_all,
                             accelerator='Ctrl-a')
        menubar.add_cascade(label='Zoom', underline=0, menu=zoommenu)

        axismenu = Tkinter.Menu(menubar, tearoff=0)
        if self._imin > 0: xstate = 'normal'
        else: xstate = 'disabled'
        if self._jmin > 0: ystate = 'normal'
        else: ystate = 'disabled'
        axismenu.add_checkbutton(label='Log X axis', underline=4,
                                 variable=self._ilog, state=xstate,
                                 command=self._log)
        axismenu.add_checkbutton(label='Log Y axis', underline=4,
                                 variable=self._jlog, state=ystate,
                                 command=self._log)
        menubar.add_cascade(label='Axes', underline=0, menu=axismenu)

        helpmenu = Tkinter.Menu(menubar, tearoff=0)
        helpmenu.add_command(label='About', underline=0,
                             command=self.about)
        helpmenu.add_command(label='Instructions', underline=0,
                             command=self.help, accelerator='F1')
        menubar.add_cascade(label='Help', underline=0, menu=helpmenu)
        
        parent.config(menu=menubar) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:42,代码来源:plot.py


注:本文中的Tkinter.Menu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。