本文整理汇总了Python中tkinter.Menubutton方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.Menubutton方法的具体用法?Python tkinter.Menubutton怎么用?Python tkinter.Menubutton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter
的用法示例。
在下文中一共展示了tkinter.Menubutton方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_upper_button
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Menubutton [as 别名]
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)
示例2: add_upper_button
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Menubutton [as 别名]
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)
示例3: add_upper_button
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Menubutton [as 别名]
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)
示例4: addMenus
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Menubutton [as 别名]
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)
示例5: create
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Menubutton [as 别名]
def create(self, **kwargs):
return tkinter.Menubutton(self.root, **kwargs)
示例6: toc_menu
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Menubutton [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
示例7: add_upper_button
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Menubutton [as 别名]
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)