Python tkinter.Menubutton() Examples
The following are 11
code examples of tkinter.Menubutton().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter
, or try the search function
.
Example #1
Source File: case.py From mentalist with MIT License | 6 votes |
def add_upper_button(self): mb = Tk.Menubutton(self.upper_frame, text=' + ', relief='raised', font=('Helvetica', '14')) mb.menu = Tk.Menu(mb, tearoff=0) mb['menu'] = mb.menu label = 'No Case Change' mb.menu.add_command(label=label, command=partial(self.controller.add_attr, label=label, node_view=self, attr_class=model.NothingMutatorAttr)) m_cases = [None, None] for i, case in enumerate(['Lowercase', 'Uppercase']): m_cases[i] = Tk.Menu(mb, tearoff=0) mb.menu.add_cascade(label='{}'.format(case), menu=m_cases[i], underline=0) for type_ in ['All', 'First']: if type_ == 'First': if case == 'Lowercase': suffix = ', Upper Rest' else: suffix = ', Lower Rest' else: suffix = '' label = '{} {}{}'.format(case, type_, suffix) m_cases[i].add_command(label=label, command=partial(self.controller.add_attr, label=label, node_view=self, attr_class=model.CaseAttr, type_=type_, case=case)) mb.menu.add_command(label='Toggle Nth...', command=partial(self.open_case_popup, 'Toggle')) mb.pack(side='left', fill='x', padx=10, pady=5)
Example #2
Source File: base_words.py From mentalist with MIT License | 5 votes |
def add_upper_button(self): mb = Tk.Menubutton(self.upper_frame, text=" + ", relief="raised", font=("Helvetica", "14")) mb.menu = Tk.Menu(mb, tearoff=0) mb["menu"] = mb.menu label = 'No Words' mb.menu.add_command(label=label, command=partial(self.controller.add_attr, label=label, node_view=self, attr_class=model.NothingAdderAttr)) mb.menu.add_command(label="Custom File...", command=partial(self.open_file_dlg, partial(self.controller.add_attr, label='File:', right_label_text='Calculating...', node_view=self, attr_class=model.FileAttr, controller=self.controller))) mb.menu.add_command(label="Custom String...", command=partial(self.open_string_popup, 'String')) self.add_file_menu(mb, mb.menu) mb.pack(side="left", fill="x", padx=10, pady=5)
Example #3
Source File: substitution.py From mentalist with MIT License | 5 votes |
def add_upper_button(self): mb = Tk.Menubutton(self.upper_frame, text=' + ', relief='raised', font=('Helvetica', '14')) mb.menu = Tk.Menu(mb, tearoff=0) mb['menu'] = mb.menu label = 'No Substitution' mb.menu.add_command(label=label, command=partial(self.controller.add_attr, label=label, node_view=self, attr_class=model.NothingMutatorAttr)) mb.menu.add_command(label='Replace All Instances...', command=partial(self.open_sub_popup, 'All')) mb.menu.add_command(label='Replace First Instance...', command=partial(self.open_sub_popup, 'First')) mb.menu.add_command(label='Replace Last Instance...', command=partial(self.open_sub_popup, 'Last')) mb.pack(side='left', fill='x', padx=10, pady=5)
Example #4
Source File: mainWindow.py From PyEveLiveDPS with GNU General Public License v3.0 | 5 votes |
def addMenus(self): # character menu options are added dynamically by CharacterDetector, so we pass this into that self.characterMenu = tk.Menubutton(text="Character...", background="black", fg="white", borderwidth="1", highlightbackground="black", highlightthickness="1", activebackground="gray25", activeforeground="white") self.characterMenu.grid(row="5", column="2") self.characterMenu.menu = tk.Menu(self.characterMenu, tearoff=False) self.characterMenu["menu"] = self.characterMenu.menu self.characterDetector = logreader.CharacterDetector(self, self.characterMenu) # Set up file menu options self.mainMenu = tk.Menubutton(text="File...", background="black", fg="white", borderwidth="1", highlightbackground="black", highlightthickness="1", activebackground="gray25", activeforeground="white") self.mainMenu.grid(row="5", column="1") self.mainMenu.menu = tk.Menu(self.mainMenu, tearoff=False) self.mainMenu["menu"] = self.mainMenu.menu self.mainMenu.menu.add_command(label="Edit Profile Settings", command=lambda: settingsWindow.SettingsWindow(self)) # add all the profiles from settings into the menu self.profileMenu = tk.Menu(self.mainMenu, tearoff=False) settings.initializeMenu(self) self.mainMenu.menu.add_cascade(label="Profile", menu=self.profileMenu) self.mainMenu.menu.add_separator() self.mainMenu.menu.add_command(label="Clear Total/Peak Values", state=tk.DISABLED) self.mainMenu.menu.add_separator() self.mainMenu.menu.add_command(label="Fleet Mode", command=lambda: fleetConnectionWindow.FleetWindow(self)) self.mainMenu.menu.add_separator() self.mainMenu.menu.add_command(label="Simulate Input", command=lambda: simulationWindow.SimulationWindow(self)) getLogFilePath = lambda: tk.filedialog.askopenfilename(initialdir=self.characterDetector.path, title="Select log file") self.mainMenu.menu.add_command(label="Playback Log", command=lambda: self.characterDetector.playbackLog(getLogFilePath())) self.mainMenu.menu.add_separator() self.mainMenu.menu.add_command(label="Quit", command=self.quitEvent)
Example #5
Source File: test_widgets.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def create(self, **kwargs): return tkinter.Menubutton(self.root, **kwargs)
Example #6
Source File: help.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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
Example #7
Source File: test_widgets.py From ironpython3 with Apache License 2.0 | 5 votes |
def create(self, **kwargs): return tkinter.Menubutton(self.root, **kwargs)
Example #8
Source File: help.py From ironpython3 with Apache License 2.0 | 5 votes |
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
Example #9
Source File: test_widgets.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def create(self, **kwargs): return tkinter.Menubutton(self.root, **kwargs)
Example #10
Source File: help.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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
Example #11
Source File: adder.py From mentalist with MIT License | 4 votes |
def add_upper_button(self): mb = Tk.Menubutton(self.upper_frame, text=" + ", relief="raised", font=("Helvetica", "14")) mb.menu = Tk.Menu(mb, tearoff=0) mb["menu"] = mb.menu label = 'No %s' % self.title mb.menu.add_command(label=label, command=partial(self.controller.add_attr, label=label, node_view=self, attr_class=model.NothingAdderAttr)) # The first few attributes are the same as BaseFile m_words = Tk.Menu(mb, tearoff=0) mb.menu.add_cascade(label='Words', menu=m_words, underline=0) m_words.add_command(label='Custom File...', command=partial(self.open_file_dlg, partial(self.controller.add_attr, label='File:', right_label_text='Calculating...', node_view=self, attr_class=model.FileAttr, controller=self.controller))) m_words.add_command(label='Custom String...', command=partial(self.open_string_popup, 'String')) self.add_file_menu(m_words, m_words) # In addition to BaseFile's attributes, we have numbers, dates, # and special characters m_numbers = Tk.Menu(mb, tearoff=0) mb.menu.add_cascade(label='Numbers', menu=m_numbers, underline=0) m_numbers.add_command(label='User Defined...', command=self.open_custom_number_dlg) for type_, range_str in NUMBER_LIST: range_ = list(map(int, range_str.split('-'))) if type_ != 'years': range_str = '-'.join(['0', locale.format('%d', range_[1], grouping=True)]) range_[1] += 1 m_numbers.add_command(label='{}: {}'.format(type_.capitalize(), range_str), command=partial( self.controller.add_attr, label='Numbers: {} {}'.format(type_.capitalize(), range_str), node_view=self, attr_class=model.RangeAttr, start=range_[0], end=range_[1])) m_numbers.add_command(label='Dates...', command=self.open_date_dlg) mb.menu.add_command(label="Special Characters...", command=self.open_special_dlg) # Area and zip codes from lookup tables for code_type in ['Area', 'Zip']: m_area_zip = Tk.Menu(mb, tearoff=0) mb.menu.add_cascade(label='{} Codes (US)'.format(code_type), menu=m_area_zip, underline=0) for location_type in ['State', 'City']: m_sub = Tk.Menu(m_area_zip, tearoff=0) m_area_zip.add_cascade(label='By {}'.format(location_type), menu=m_sub, underline=0) target_list = sorted(model.location_codes[location_type][code_type].keys()) for st in target_list: label = '{} Codes: {} {}'.format(code_type, st, location_type if location_type == 'State' else '') m_sub.add_command(label=st, command=partial( self.controller.add_attr, label=label, node_view=self, attr_class=model.LocationCodeAttr, code_type=code_type, location=st, location_type=location_type)) mb.pack(side="left", fill="x", padx=10, pady=5)