当您查看应用程序的菜单栏时,有一个粗体菜单,其中包含应用程序的名称,在该菜单中有一个关于选项。你如何在python 3中使用tkinter编辑这个关于菜单
经过一番研究,我找到了答案:
from tkinter import *
class App():
def __init__(self):
self.tk=Tk()
def show_about_menu(self): #function for about window
Label(Toplevel(self.tk),text='An about menu.').pack()
def show_help(self): #function for help window
Message(Toplevel(self.tk),text='There are a series of generalised events in tkinter. Some of which are OS specific, such as any starting with "tk::mac::". Others are more general such as "tkAboutDialog", which is used when the menu option "<app>/About <app>" is called.').pack()
def show_preferences(self): #function for preferences window
Label(Toplevel(self.tk),text='Some preferences.').pack()
def start(self):
self.tk.createcommand('tkAboutDialog',self.show_about_menu) #set about menu
self.tk.createcommand('tk::mac::ShowPreferences',self.show_preferences) #set preferences menu
self.tk.createcommand('tk::mac::ShowHelp',self.show_help) #set help menu
self.tk.mainloop()
if __name__=='__main__':
App().start()