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


Python Menu.add_command方法代码示例

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


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

示例1: viewRenderedGrid

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
def viewRenderedGrid(modelXbrl, tabWin, lang=None):
    modelXbrl.modelManager.showStatus(_("viewing rendering"))
    view = ViewRenderedGrid(modelXbrl, tabWin, lang)
        
    view.blockMenuEvents = 1

    menu = view.contextMenu()
    optionsMenu = Menu(view.viewFrame, tearoff=0)
    optionsMenu.add_command(label=_("New fact item options"), underline=0, command=lambda: getNewFactItemOptions(modelXbrl.modelManager.cntlr, view.newFactItemOptions))
    optionsMenu.add_command(label=_("Open breakdown entry rows"), underline=0, command=view.setOpenBreakdownEntryRows)
    view.ignoreDimValidity.trace("w", view.viewReloadDueToMenuAction)
    optionsMenu.add_checkbutton(label=_("Ignore Dimensional Validity"), underline=0, variable=view.ignoreDimValidity, onvalue=True, offvalue=False)
    view.xAxisChildrenFirst.trace("w", view.viewReloadDueToMenuAction)
    optionsMenu.add_checkbutton(label=_("X-Axis Children First"), underline=0, variable=view.xAxisChildrenFirst, onvalue=True, offvalue=False)
    view.yAxisChildrenFirst.trace("w", view.viewReloadDueToMenuAction)
    optionsMenu.add_checkbutton(label=_("Y-Axis Children First"), underline=0, variable=view.yAxisChildrenFirst, onvalue=True, offvalue=False)
    menu.add_cascade(label=_("Options"), menu=optionsMenu, underline=0)
    view.tablesMenu = Menu(view.viewFrame, tearoff=0)
    menu.add_cascade(label=_("Tables"), menu=view.tablesMenu, underline=0)
    view.tablesMenuLength = 0
    view.menuAddLangs()
    saveMenu = Menu(view.viewFrame, tearoff=0)
    saveMenu.add_command(label=_("HTML file"), underline=0, command=lambda: view.modelXbrl.modelManager.cntlr.fileSave(view=view, fileType="html"))
    saveMenu.add_command(label=_("Layout model"), underline=0, command=lambda: view.modelXbrl.modelManager.cntlr.fileSave(view=view, fileType="xml"))
    saveMenu.add_command(label=_("XBRL instance"), underline=0, command=view.saveInstance)
    menu.add_cascade(label=_("Save"), menu=saveMenu, underline=0)
    menu.add_command(label=_("Enter new facts..."), underline=0, command=view.enterNewFacts)
    view.view()
    view.blockSelectEvent = 1
    view.blockViewModelObject = 0
    view.viewFrame.bind("<Enter>", view.cellEnter, '+')
    view.viewFrame.bind("<Leave>", view.cellLeave, '+')
    view.viewFrame.bind("<1>", view.onClick, '+')
    view.blockMenuEvents = 0
开发者ID:irjudson,项目名称:Arelle,代码行数:36,代码来源:ViewWinRenderedGrid.py

示例2: Example

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
class Example(Frame):
  
    def __init__(self):
        super().__init__()   
         
        self.initUI()
        
        
    def initUI(self):
      
        self.master.title("Popup menu")
        self.menu = Menu(self.master, tearoff=0)
        self.menu.add_command(label="Beep", command=self.bell)
        self.menu.add_command(label="Exit", command=self.onExit)

        self.master.bind("<Button-3>", self.showMenu)
        self.pack()
        
        
    def showMenu(self, e):
        
        self.menu.post(e.x_root, e.y_root)
       

    def onExit(self):
        
        self.quit()
开发者ID:rinkeigun,项目名称:linux_module,代码行数:29,代码来源:tkpopup.py

示例3: handle_button_click

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
    def handle_button_click(self, event):

        val = self.button_selected.get() - 1
        val = self.radio_buttons.index(event.widget)
        if event.state & 0x001:  # Shift key down
            self.x_flipped[val] = not self.x_flipped[val]
            try:
                raise IOError
                image_file = imget(self.img_lists[val][self.images_selected[val]])
                import_image = Image.open(image_file)
            except IOError:
                image_file = imget_bdgp(self.img_lists[val][self.images_selected[val]])
                import_image = Image.open(image_file)
                import_image = import_image.resize((180,80), Image.ANTIALIAS)
            import_image = import_image.rotate(180*self.x_flipped[val])
            embryo_image = ImageTk.PhotoImage(import_image)
            label = Label(image=embryo_image)
            label.image = embryo_image
            self.radio_buttons[val].configure(
                #text=image_file,
                image=label.image,
            )
        elif event.state & 0x004: # Control key down
            popup = Menu(root, tearoff=0)
            popup.add_command(label=self.radio_buttons[val].cget('text'))
            popup.add_separator()
            popup.add_command(label="Invert X")
            popup.add_command(label="Invert Y")
            try:
                popup.tk_popup(event.x_root, event.y_root, 0)
            finally:
                # make sure to release the grab (Tk 8.0a1 only)
                popup.grab_release()

        elif val >= 0:
            self.images_selected[val] = ((self.images_selected[val] + 2*event.num
                                         - 3) %
                                         len(self.img_lists[val]))
            self.x_flipped[val] = False
            if self.images_selected[val] == 0:
                stdout.write('\a')
                stdout.flush()

            try:
                raise IOError
                image_file = imget(self.img_lists[val][self.images_selected[val]])
                import_image = Image.open(image_file)
            except IOError:
                image_file = imget_bdgp(self.img_lists[val][self.images_selected[val]])
                import_image = Image.open(image_file)
                import_image = import_image.resize((180,80), Image.ANTIALIAS)
            embryo_image = ImageTk.PhotoImage(import_image)
            label = Label(image=embryo_image)
            label.image = embryo_image
            self.radio_buttons[val].configure(
                #text=image_file,
                image=label.image,
            )
            self.image_files[val] = image_file
        self.button_selected.set(-1)
开发者ID:petercombs,项目名称:EisenLab-Code,代码行数:62,代码来源:MakeInSituTable.py

示例4: DataEntry

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
class DataEntry(object):

	def __init__(self, parent_frame, grid_col, grid_row, data):

		self._data = data
		self._parent = parent_frame

		self._frame = ttk.Frame(self._parent, borderwidth=2, relief='sunken')
		self._frame.grid(column=grid_col, row=grid_row)

		self._menu = Menu(master=self._parent, tearoff=0)
		self._menu.add_command(label='info', command=self.info_popup)

		self._should_plot = tk.BooleanVar()
		self._should_plot.set(False)

		def menu_popup(event):
			self._menu.post(event.x_root, event.y_root)

		self._chkbox = ttk.Checkbutton(self._frame, text="Plot",
			variable=self._should_plot, onvalue=True)
		self._chkbox.pack()

		self._button = ttk.Button(self._frame,
			text="{} -> {}".format(grid_row, grid_col),
			command=self.info_popup
		)
		self._button.pack()

		self._button.bind('<Button-3>', menu_popup)

	@property
	def data(self):
		return self._data

	@property
	def should_plot(self):
		return self._should_plot.get()

	def info_popup(self):
		top = Toplevel()
		top.title("Info")

		frame = ttk.Frame(top)
		frame.pack()

		sourceLbl = ttk.Label(frame, text="Source")
		targetLbl = ttk.Label(frame, text="Target")

		sourceText = ttk.Label(frame, text=str(self._data._source),
			relief='sunken')
		targetText = ttk.Label(frame, text=str(self._data._target),
			relief='sunken')

		sourceLbl.grid(column=0, row=0)
		targetLbl.grid(column=1, row=0)
		sourceText.grid(column=0, row=1, padx=5, pady=5)
		targetText.grid(column=1, row=1, padx=5, pady=5)
开发者ID:haf,项目名称:cheesepi,代码行数:60,代码来源:data_explorer.py

示例5: __init__

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)

        self.parent = parent
        self.parent.option_add('*tearOff', False)
        self.after(50, self.onAfter)

        #set this frame to expand to %100 available space
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        #init menu
        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)

        fileMenu = Menu(menubar)
        fileMenu.add_command(label="Save", command=self.onSave)
        fileMenu.add_command(label="Load", command=self.onLoad)
        fileMenu.add_command(label="Exit", command=self.onExit)
        menubar.add_cascade(label="File", menu=fileMenu)

        #init textbox
        self.text = ScrolledText(self, wrap='word')

        #add widgets to the layout manager
        self.text.grid(sticky=inflate)
开发者ID:darkmushroom,项目名称:holdmydictation,代码行数:28,代码来源:holdmydictation.py

示例6: initUI

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
    def initUI(self):
        self.parent.title('PyZilla')
        self.padding = 5

        self.pack(fill=BOTH, expand=1)

        # Create a menubar
        mnuMenu = Menu(self.parent)
        self.parent.config(menu=mnuMenu)

        # Create menubar
        mnuFileMenu = Menu(mnuMenu)

        # Add File menu items
        mnuFileMenu.add_command(label='Open', command=self.onBtnOpenFile)
        mnuFileMenu.add_command(label='Exit', command=self.quit)

        # Add File menu items to File menu
        mnuMenu.add_cascade(label='File', menu=mnuFileMenu)

        # Create frame for all the widgets
        frame = Frame(self)
        frame.pack(anchor=N, fill=BOTH)

        # Create file open dialog
        btnOpenFile = Button(frame, text="Load file", command=self.onBtnOpenFile)
        btnOpenFile.pack(side=RIGHT, pady=self.padding)

        # Create filename label
        self.lblFilename = Label(frame, text='No filename chosen...')
        self.lblFilename.pack(side=LEFT, pady=self.padding, padx=self.padding)

        # Create the text widget for the results
        self.txtResults = Text(self)
        self.txtResults.pack(fill=BOTH, expand=1, pady=self.padding, padx=self.padding)
开发者ID:claudemuller,项目名称:pyzilla,代码行数:37,代码来源:pyzilla.py

示例7: __init__

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
 def __init__(self, master=None):
     Frame.__init__(self, master)
     self.pack(expand=1, fill='both')
     self.master.geometry('1440x900')
     paned_window = PanedWindow(self)
     self.treeview_kspelements = TreeviewKSPElements(self)
     self.treeview_kspobjects = TreeviewKSPObjects(self)
     paned_window.pack(expand=1, fill='both')
     paned_window.add(self.treeview_kspelements)
     paned_window.add(self.treeview_kspobjects)
     
     menubar = Menu(self)
     
     filemenu = Menu(self)
     filemenu.add_command(label='Open', command=self._open)
     filemenu.add_command(label='Save', command=self._save)
     filemenu.add_command(label='Save As', command=self._save_as)
     filemenu.add_separator()
     filemenu.add_command(label='Exit', command=self.master.destroy)
     menubar.add_cascade(menu=filemenu, label='File')
     
     insertmenu = Menu(self)
     insertmenu.add_command(label='KSP Element', command=self._insert_element, state='disabled')
     insertmenu.add_command(label='KSP Object', command=self._insert_object)
     menubar.add_cascade(menu=insertmenu, label='Insert')
     self.master.config(menu=menubar)
开发者ID:dan2082,项目名称:KSPData,代码行数:28,代码来源:main.py

示例8: _init_menubar

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [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:DrDub,项目名称:nltk,代码行数:27,代码来源:tree.py

示例9: add_menubar

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
def add_menubar(root):
    menubar = Menu(root)

    # file menu
    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Load project", command=build_in_progress)
    filemenu.add_command(label="Save project", command=build_in_progress)
    filemenu.add_separator()
    filemenu.add_command(label="Exit", command=root.quit)

    menubar.add_cascade(label="File", menu=filemenu)

    # view menu
    viewmenu = Menu(menubar, tearoff=0)
    viewmenu.add_command(label="Progress", command=root.progress)
    viewmenu.add_command(label="Workflow", command=root.workflow)

    menubar.add_cascade(label="View", menu=viewmenu)

    # help menu
    helpmenu = Menu(menubar, tearoff=0)
    helpmenu.add_command(label="Help", command=build_in_progress)
    helpmenu.add_separator()
    helpmenu.add_command(label="About", command=about)

    menubar.add_cascade(label="Help", menu=helpmenu)

    root.config(menu=menubar)
开发者ID:CCBR,项目名称:Pipeliner,代码行数:30,代码来源:menu.py

示例10: Example

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
class Example(Frame):
  
    def __init__(self):
        super().__init__()
         
        self.initUI()

        
    def initUI(self):
      
        self.master.title("Toolbar")
        
        menubar = Menu(self.master)
        self.fileMenu = Menu(self.master, tearoff=0)
        self.fileMenu.add_command(label="Exit", command=self.onExit)
        menubar.add_cascade(label="File", menu=self.fileMenu)
        
        toolbar = Frame(self.master, bd=1, relief=RAISED)

        self.img = Image.open("images.png")
        eimg = ImageTk.PhotoImage(self.img)  

        exitButton = Button(toolbar, image=eimg, relief=FLAT,
            command=self.quit)
        exitButton.image = eimg
        exitButton.pack(side=LEFT, padx=2, pady=2)
       
        toolbar.pack(side=TOP, fill=X)
        self.master.config(menu=menubar)
        self.pack()
        
       
    def onExit(self):
        self.quit()
开发者ID:rinkeigun,项目名称:linux_module,代码行数:36,代码来源:tktoolbar.py

示例11: BuildScriptMenu

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
 def BuildScriptMenu(self,parentmenu,modulename):
     from tkinter import Menu
     menu = Menu(parentmenu,bd=1,activeborderwidth=0)
     try:
         module = importlib.import_module('vmtk.'+modulename)
     except ImportError:
         return None
     scriptnames = [scriptname for scriptname in getattr(module, '__all__')]
     for index, scriptname in enumerate(scriptnames):
         # check if scriptname contains starting prefix 'vmtk.' and remove it before returning list to the user.
         if 'vmtk.' == scriptname[0:5]:
             splitList = scriptname.split('.')
             scriptnames[index] = splitList[1]
         else:
             continue
     menulength = 20
     for i in range(len(scriptnames)//menulength+1):
         subscriptnames = scriptnames[i*menulength:(i+1)*menulength]
         if not subscriptnames:
             break 
         submenu = Menu(menu,bd=1,activeborderwidth=0)
         menu.add_cascade(label=subscriptnames[0]+"...",menu=submenu)
         for scriptname in subscriptnames:
             callback = CallbackShim(self.InsertScriptName,scriptname)
             submenu.add_command(label=scriptname,command=callback)
     return menu 
开发者ID:samsmu,项目名称:vmtk,代码行数:28,代码来源:pypepad.py

示例12: init_ui

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
    def init_ui(self):
        """getting all things started"""
        self.parent.title("PyMeno")
        self.left_list.bind("<Double-Button-1>", self.on_double_click)
        self.parent.config(menu=self.menu_bar)
        file_menu = Menu(self.menu_bar, tearoff=False)
        menu2_parse = Menu(self.menu_bar, tearoff=False)
        # menu3_parse = Menu(menu_bar, tearoff=False)
        # sub_menu = Menu(file_menu, tearoff=False)
        self.left_list.pack(side=LEFT, fill=BOTH, expand=2)
        self.right_list.pack(side=RIGHT, fill=BOTH, expand=2)

        # add something to menu

        file_menu.add_command(label="Choose folder with music ALG 1",
                              underline=0, command=self.new_thread_2)
        file_menu.add_command(label="Choose folder with music ALG 2",
                              underline=0, command=self.new_thread_1)
        file_menu.add_command(label="Choose folder with music ALG 3",
                              underline=0, command=self.new_thread_2)
        file_menu.add_command(label="Exit", underline=0, command=self.on_exit)

        menu2_parse.add_command(label="Download artists list", underline=0,
                                command=self.db_creator.download_list_of_artists)
        menu2_parse.\
            add_command(label="Parse artists information to database", underline=0,
                        command=self.go_to_lilis_parsing)

        self.menu_bar.add_cascade(label="File", underline=0, menu=file_menu)
        self.menu_bar.add_cascade(label="Data", underline=0, menu=menu2_parse)
开发者ID:Monk-,项目名称:PyMeno,代码行数:32,代码来源:gui.py

示例13: FrontEnd

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
class FrontEnd(Frame):
    def __init__(self, master, version):
        Frame.__init__(self, master)
        master.title(version[:-5])
        # MAKE IT LOOK GOOD
        style = Style()
        style.configure("atitle.TLabel", font="tkDefaultFont 12 bold italic")

        # CREATE AND SET VARIABLES
        self.version = version
        self.description = None
        self.logo = None
        self.status_lbl = StringVar()  # TO HOLD STATUS VARIABLE IN STATUSBAR

        # CREATE ROOT MENUBAR
        menubar = Menu(self.master)
        self.master["menu"] = menubar
        self.master.option_add("*tearOff", False)
        # CREATE FILE MENU
        self.menu_file = Menu(menubar, name="file")
        self.menu_file.add_separator()
        self.menu_file.add_command(label="Exit", accelerator="Alt-F4", command=self.master.destroy)
        menubar.add_cascade(menu=self.menu_file, label="File", underline=0)
        # CREATE HELP MENU
        menu_help = Menu(menubar, name="help")
        menu_help.add_command(label="About", command=self.show_about)
        menubar.add_cascade(menu=menu_help, label="Help", underline=0)

        # CREATE BUTTON BAR
        self.button_bar = Frame(self.master, relief="groove", padding="0 1 0 2")
        self.button_bar.grid(sticky="ew")

        # SETUP PRIMARY FRAME FOR WIDGETS
        self.frame = Frame(self.master, padding="25")
        self.frame.grid(sticky="nsew")

        # CREATE STATUS BAR
        Separator(self.master).grid(row=8, sticky="ew")
        self.status_bar = Frame(self.master, padding="8 0 0 1")
        self.status_bar.grid(row=9, sticky="ews")
        Label(self.status_bar, textvariable=self.status_lbl).grid(row=0, column=0, padx="0 7")
        Label(self.status_bar, text=self.version[-5:]).grid(row=0, column=8)
        Sizegrip(self.status_bar).grid(row=0, column=9, sticky="e")

        # CONFIGURE AUTO-RESIZING
        self.master.columnconfigure(0, weight=1)
        self.master.rowconfigure(1, weight=1)
        self.frame.columnconfigure(0, weight=1)
        # self.frame.rowconfigure(0, weight=1)
        self.status_bar.columnconfigure(1, weight=1)

    def show_about(self):
        about = About(self.master, "About {}".format(self.version[:-5]), self.logo)
        Label(about.frame, text=self.version, style="atitle.TLabel").grid(sticky="w")
        Label(about.frame, text="Developer:  Joel W. Dafoe").grid(pady="6", sticky="w")
        link = Link(about.frame, text="http://cyberdatx.com", foreground="blue", cursor="hand2")
        link.grid(sticky="w")
        link.bind("<Button-1>", lambda e: webbrowser.open("http://cyberdatx.com"))
        Label(about.frame, text=self.description, wraplength=292).grid(columnspan=2, pady=6, sticky=W)
开发者ID:jwdafoe,项目名称:ContactPro,代码行数:61,代码来源:gui.py

示例14: contents_widget

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
 def contents_widget(self, text):
     "Create table of contents."
     toc = Menubutton(self, text='TOC')
     drop = Menu(toc, tearoff=False)
     for tag, lbl in text.parser.contents:
         drop.add_command(label=lbl, command=lambda mark=tag:text.see(mark))
     toc['menu'] = drop
     return toc
开发者ID:invisiblek,项目名称:android_external_python,代码行数:10,代码来源:help.py

示例15: toc_menu

# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import add_command [as 别名]
 def toc_menu(self, text):
     "Create table of contents as drop-down menu."
     toc = Menubutton(self, text='TOC')
     drop = Menu(toc, tearoff=False)
     for lbl, dex in text.parser.toc:
         drop.add_command(label=lbl, command=lambda dex=dex:text.yview(dex))
     toc['menu'] = drop
     return toc
开发者ID:whqkdhfh13,项目名称:sswp,代码行数:10,代码来源:help.py


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