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


Python tkinter.Menu类代码示例

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


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

示例1: viewFacts

def viewFacts(modelXbrl, tabWin, header="Fact Table", arcrole=XbrlConst.parentChild, linkrole=None, linkqname=None, arcqname=None, lang=None, expandAll=False):
    modelXbrl.modelManager.showStatus(_("viewing relationships {0}").format(os.path.basename(arcrole)))
    view = ViewFactTable(modelXbrl, tabWin, header, arcrole, linkrole, linkqname, arcqname, lang, expandAll)
    view.ignoreDims = BooleanVar(value=False)
    view.showDimDefaults = BooleanVar(value=False)
    if view.view():
        view.treeView.bind("<<TreeviewSelect>>", view.treeviewSelect, '+')
        view.treeView.bind("<ButtonRelease-1>", view.treeviewClick, '+')
        view.treeView.bind("<Enter>", view.treeviewEnter, '+')
        view.treeView.bind("<Leave>", view.treeviewLeave, '+')

        # languages menu
        menu = view.contextMenu()
        optionsMenu = Menu(view.viewFrame, tearoff=0)
        view.ignoreDims.trace("w", view.viewReloadDueToMenuAction)
        optionsMenu.add_checkbutton(label=_("Ignore Dimensions"), underline=0, variable=view.ignoreDims, onvalue=True, offvalue=False)
        menu.add_cascade(label=_("Options"), menu=optionsMenu, underline=0)
        view.menuAddExpandCollapse()
        view.menuAddClipboard()
        view.menuAddLangs()
        view.menuAddLabelRoles(includeConceptName=True)
        #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"))
        #menu.add_cascade(label=_("Save"), menu=saveMenu, underline=0)
    return view
开发者ID:acsone,项目名称:Arelle,代码行数:25,代码来源:ViewWinFactTable.py

示例2: Example

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,代码行数:34,代码来源:tktoolbar.py

示例3: initUI

 def initUI(self):
 
    self.menu_file = Menu(self)
    self.menu_file.add_command(label='Load 3D')
    self.menu_file.add_command(label='Load 2D')

    self.menu_file.add_command(label='Exit',command=self.delegate.quit)
    
    self.add_cascade(menu=self.menu_file, label='File')

    self.menu_Filter = Menu(self)
    
    self.b0 = BooleanVar()
    self.b1 = BooleanVar()
    self.b2 = BooleanVar()
    self.b3 = BooleanVar()

    self.menu_Filter.add_checkbutton(label="Speech 3D", onvalue=1, offvalue=0, variable=self.b0, command=self.delegate.speech3DButtonPressed)
    self.menu_Filter.add_checkbutton(label='Speech 2D',onvalue=1, offvalue=0, variable=self.b1, command=self.delegate.speech2DButtonPressed)
    self.menu_Filter.add_checkbutton(label='Swallow 3D',onvalue=1, offvalue=0, variable=self.b2,command=self.delegate.swallow3DButtonPressed)
    self.menu_Filter.add_checkbutton(label='Swallow 2D',onvalue=1, offvalue=0, variable=self.b3,command=self.delegate.swallow2DButtonPressed)

    self.add_cascade(menu=self.menu_Filter, label='Filter')
    
    self.entryconfigure('Filter', state = 'disabled')
开发者ID:VrishtiDutta,项目名称:EGUANA_Python,代码行数:25,代码来源:egmenu.py

示例4: createWidgets

    def createWidgets(self):    
        tabControl = ttk.Notebook(self.win)     
        tab1 = ttk.Frame(tabControl)            
        tabControl.add(tab1, text='Tab 1')    
        tabControl.pack(expand=1, fill="both")  
        self.monty = ttk.LabelFrame(tab1, text=' Monty Python ')
        self.monty.grid(column=0, row=0, padx=8, pady=4)        
        
        ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W')
        self.name = tk.StringVar()
        nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name)
        nameEntered.grid(column=0, row=1, sticky='W')

        self.action = ttk.Button(self.monty, text="Click Me!")   
        self.action.grid(column=2, row=1)
        
        ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0)
        number = tk.StringVar()
        numberChosen = ttk.Combobox(self.monty, width=12, textvariable=number)
        numberChosen['values'] = (42)
        numberChosen.grid(column=1, row=1)
        numberChosen.current(0)
   
        scrolW = 30; scrolH = 3
        self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD)
        self.scr.grid(column=0, row=3, sticky='WE', columnspan=3)

        menuBar = Menu(tab1)
        self.win.config(menu=menuBar)
        fileMenu = Menu(menuBar, tearoff=0)
        menuBar.add_cascade(label="File", menu=fileMenu)
        helpMenu = Menu(menuBar, tearoff=0)
        menuBar.add_cascade(label="Help", menu=helpMenu)

        nameEntered.focus()     
开发者ID:xenron,项目名称:sandbox-dev-python,代码行数:35,代码来源:B04829_Ch11_GUI_OOP.py

示例5: __init__

    def __init__(self):
        """ Create the initial application GUI environment (tool bars, and other static elements) """
        Frame.__init__(self, self.root)
        self.thread_entry_field = ''  # Hold both search string, and drives autoRefresh logic

        self.menuBar = Menu()
        self.fileMenu = Menu(self.menuBar, tearoff=0)
        self.menuBar.add_cascade(label="File", menu=self.fileMenu, underline=1)
        self.fileMenu.add_command(label="Quit", command=self.root.destroy, underline=1)

        self.optionsMenu = Menu(self.menuBar, tearoff=0)
        self.menuBar.add_cascade(label="Options", menu=self.optionsMenu)
        self.optionsMenu.add_command(label="Settings", command=self.editSettings, underline=1)
        self.helpMenu = Menu(self.menuBar, tearoff=0)
        self.menuBar.add_cascade(label="Help", menu=self.helpMenu)
        self.helpMenu.add_command(label="Help", command=self.program_help, underline=1)
        self.helpMenu.add_command(label="About", command=self.program_about, underline=1)
        self.master.config(menu=self.menuBar)

        self.topFrame = Frame()
        self.thread_entry_box = Entry(self.topFrame)
        self.thread_entry_box.insert(0, self.DEFAULT_THREAD_TEXT)
        self.thread_entry_box.bind('<Return>', lambda event: self.add_thread_GUI())
        # Bind needs to send the event to the handler
        self.thread_entry_box.pack(side='left', fill='x', expand='True', padx=5)

        self.add_thread_btn = Button(self.topFrame)
        self.add_thread_btn['text'] = 'Add New Thread'
        self.add_thread_btn['command'] = lambda: self.add_thread_GUI()
        self.add_thread_btn.pack(side='left', padx=0)

        self.topFrame.pack(fill='x')

        self.create_thread_frame()
开发者ID:Jelloeater,项目名称:chanThreadWatcher,代码行数:34,代码来源:view.py

示例6: __init__

    def __init__(self):

        self.master = Tk()
        self.master.geometry(newGeometry = '300x300')
        # Fenêtre tkinter

        self.menu = Menu(self.master)

        self.filemenu = Menu(self.menu,
                             tearoff = 0)
        self.filemenu.add_command(label = "Open", command = self.open)
        self.filemenu.add_separator()
        self.filemenu.add_command(label = "Exit", command = self.master.destroy)
        self.menu.add_cascade(label = "File",
                              menu = self.filemenu)

        self.master.config(menu = self.menu)
        # On crée un menu

        self.canvas = Canvas(master=self.master,
                             width=200,
                             height=200,
                             bg='#cccccc')

        self.canvas.place(x=150,
                          y=100,
                          anchor='center')

        Label(master=self.master,
              text='Image',
              font='YuMinchoDemibold',
              foreground='white',
              background='#535353').place(x=120,
                                          y=190)
开发者ID:Pythalex,项目名称:PyResize,代码行数:34,代码来源:PyResize.py

示例7: __init__

    def __init__(self):
        # Initialize the text editor
        self.root = tk.Tk(className='Tekstieditori')

        # Text editor text area
        self.textpad = tkst.ScrolledText(self.root,
                                         width=100,
                                         height=36,
                                         highlightthickness=0)

        # Text area, inner padding and font config added
        self.textpad.config(font=('tkDefaultFont', 16, 'normal'),
                            padx=10,
                            pady=10)

        # Add text area to parent
        self.textpad.pack()

        # Create a file menu in menu bar
        self.menu = Menu(self.root)
        self.filemenu = Menu(self.menu)
        self.file_menu_conf()

        self.file = {}

        # Initialize the selection index class variable
        self.sel_index = [0, 1]

        # Configurate click events
        self.event_config()
开发者ID:SputnikToGo,项目名称:PythonTextEditor,代码行数:30,代码来源:TextEditor.py

示例8: FrontEnd

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,代码行数:59,代码来源:gui.py

示例9: contents_widget

 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,代码行数:8,代码来源:help.py

示例10: toc_menu

 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,代码行数:8,代码来源:help.py

示例11: DataEntry

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,代码行数:58,代码来源:data_explorer.py

示例12: add_menus

    def add_menus(self):
        menu_bar = Menu(self.root)
        stampede_menu = Menu(menu_bar, tearoff=0)
        stampede_menu.add_command(label="Settings", command=self.edit_default_settings)
        stampede_menu.add_separator()
        stampede_menu.add_command(label="Quit", command=self.root.quit)
        menu_bar.add_cascade(label="Stampede", menu=stampede_menu)

        self.root.config(menu=menu_bar)
开发者ID:qcaron,项目名称:stampede,代码行数:9,代码来源:main.py

示例13: main

def main():
    root = Tk()
    root.geometry("600x185+200+200")
    app = MemberChecker(root)
    menubar = Menu(root)
    menubar.add_command(label="Clear log", command=app.clear_log)
    menubar.add_command(label="Load API data", command=app.load_data)
    root.config(menu=menubar)
    root.pack_slaves()
    root.mainloop()
开发者ID:FKint,项目名称:LitusMemberChecker,代码行数:10,代码来源:__init__.py

示例14: add_menu

 def add_menu(self):
     top = self.root
     top["menu"] = menubar = Menu(top)
     menu_file = Menu(menubar)
     menu_settings = Menu(menubar)
     menu_help = Menu(menubar)
     menubar.add_cascade(menu=menu_file, label=_("File"))
     menubar.add_cascade(menu=menu_settings, label=_("Settings"))
     menubar.add_cascade(menu=menu_help, label=_("Help"))
     menu_settings.add_command(label=_("Pannel Settings"),
                               command=self.dlg_panset)
开发者ID:Lysovenko,项目名称:bpc,代码行数:11,代码来源:face.py

示例15: __init__

    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,代码行数:26,代码来源:holdmydictation.py


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