本文整理汇总了Python中tkinter.Menu.entryconfig方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.entryconfig方法的具体用法?Python Menu.entryconfig怎么用?Python Menu.entryconfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Menu
的用法示例。
在下文中一共展示了Menu.entryconfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import entryconfig [as 别名]
class MenuGui:
def __init__(self, main_controller, window):
self.__window = window
self.__main_controller = main_controller
self.__menu = None
def show(self):
if self.__menu is None:
self.__menu = Menu(self.__window)
self.__menu.add_command(label="save", command=self.__save)
self.__menu.add_command(label="back to main menu", command=self.__back)
self.__window.config(menu=self.__menu)
def remove(self):
if self.__menu is not None:
self.__menu.destroy()
self.__menu = None
def disable(self):
for i in range(3):
self.__menu.entryconfig(i, state="disabled")
def enable(self):
for i in range(3):
self.__menu.entryconfig(i, state="normal")
def __save(self):
self.__main_controller.show_save_menu()
def __back(self):
self.__main_controller.show_main_menu()
示例2: GUI
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import entryconfig [as 别名]
class GUI(Frame): # pylint: disable=too-many-ancestors
"""class for GUI"""
static_logger = logging.getLogger(__name__)
static_queue = queue.Queue()
def __init__(self, parent, db, pab, alg):
"""init"""
Frame.__init__(self, parent)
self.right_list = Listbox(parent)
self.left_list = Listbox(parent)
self.parent = parent
self.db_creator = db
self.path_and_bag = pab
self.alg_do = alg
self.menu_bar = Menu(self.parent)
self.init_ui()
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)
def on_exit(self):
"""quit"""
GUI.static_queue.put("endino-tarantino")
self.quit()
def disable_menu(self):
"""disable menu while program is working"""
self.menu_bar.entryconfig("File", state="disabled")
self.menu_bar.entryconfig("Data", state="disabled")
def enable_menu(self):
"""enable menu after work"""
self.menu_bar.entryconfig("File", state="normal")
self.menu_bar.entryconfig("Data", state="normal")
def new_thread_1(self):
"""thread for the first algorythm"""
dir_name = filedialog.askdirectory(parent=self, initialdir="/",
title='Please select a directory')
if dir_name != "":
self.disable_menu()
self.path_and_bag.check_if_refresh(dir_name)
self.config(cursor="wait")
self.update()
self.clean_queue()
GUI.static_queue.put("Finding files in chosen folder:\n\n")
num_files = len([val for sub_list in
[[os.path.join(i[0], j)for j in i[2]]
for i in os.walk(dir_name)]
for val in sub_list])
rott = tk.Tk()
app = App(rott, GUI.static_queue, num_files)
rott.protocol("WM_DELETE_WINDOW", app.on_closing)
thread = threading.Thread(target=self.open_menu, args=(dir_name,))
thread.setDaemon(True)
thread.start()
app.mainloop()
else:
print("Action aborted")
def open_menu(self, dir_name):
"""select directory with music, alg 1"""
list_of_songs = []
self.path_and_bag.clear_bag_of_words()
for data in os.walk(dir_name):
for filename in data[2]:
list_of_songs = self.path_and_bag.change_title(os.path.join(data[0], filename))
GUI.static_queue.put(filename)
if not list_of_songs:
print("action aborted")
else:
#.........这里部分代码省略.........
示例3: CimApp
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import entryconfig [as 别名]
#.........这里部分代码省略.........
height=400,
menu=self.menubar)
self.bind_all("<Control-o>", self.load_file)
self.bind_all("<Control-s>", self.file_save)
self.bind_all("<Control-Alt-s>", self.file_save_as)
self.bind_all("<Control-t>", self.convert_file)
self.bind_all("<Control-b>", self.flash_file)
self.bind_all("<Control-w>", self.close_file)
self.master.protocol("WM_DELETE_WINDOW", self.file_quit)
self.file_tabs = Notebook(self)
self.file_tabs.bind_all("<<NotebookTabChanged>>", self.file_changed)
self.file_tabs.pack(expand=1, fill="both")
def file_changed(self, event):
if len(self.file_tabs.tabs()) <= 0:
self.add_file()
return
title = str(event.widget.tab(event.widget.index("current"),"text")).upper().strip()
self.menu_program.delete(3, END)
for tab in self.file_tabs.tabs():
tabtext = self.file_tabs.tab(self.file_tabs.index(tab),"text")
if tabtext.upper().strip() == title:
self.current_tab.set(tab)
self.menu_program.add_radiobutton(label=tabtext, command=self.program_switch,
underline=1, value=tab, variable=self.current_tab)
if title != "PYTHON" or title != "TIBORCIM":
if self.current_file().filename is not None:
self.master.title(self.current_file().get_file() + " - Tiborcim")
else:
self.master.title("Tiborcim")
if str(self.current_file().tab(self.current_file().index("current"),"text")).upper().strip() == "TIBORCIM":
self.menubar.entryconfig("Edit", state=NORMAL)
else:
self.menubar.entryconfig("Edit", state=DISABLED)
self.viewmode.set(self.current_file().viewmode)
if title == "PYTHON":
self.menubar.entryconfig("Edit", state=DISABLED)
self.current_file().viewmode = "python";
self.viewmode.set("python");
if title == "TIBORCIM":
self.menubar.entryconfig("Edit", state=NORMAL)
self.current_file().viewmode = "tiborcim";
self.viewmode.set("tiborcim");
def add_file(self, file=None):
filepage = CimFilePage(self.file_tabs)
if file is None:
self.file_tabs.add(filepage, text="Unsaved Program")
else:
filepage.load_file(file)
self.file_tabs.add(filepage, text=filepage.get_file())
self.files.append(filepage)
self.file_tabs.select(filepage)
def view_tiborcim(self, event=None):
self.current_file().view_tiborcim()
def view_python(self, event=None):
self.current_file().view_python()
def program_switch(self):
self.file_tabs.select(self.current_tab.get())
def new_file(self, event=None):