2024-10-01 11:38:03 发布
网友
我正在尝试用tkinter构建一个应用程序。我正在使用Mac OS Big-Sur,我在tkinter{}方面有点困难
tkinter
(当你想看到打开的菜单栏时,你是如何截图的哈哈)
在默认mac菜单栏中添加菜单项没有问题,但我想删除一些无用的菜单项。我看到您可以使用此命令自定义“首选项”项。 root.createcommand('tk::mac::ShowPreferences', showMyPreferencesDialog) 但是我找不到别的东西了。这可能吗
root.createcommand('tk::mac::ShowPreferences', showMyPreferencesDialog)
遗憾的是,我没有足够的声誉发表评论。回答您的子问题:您可以按Cmd+Shift+3进行全屏截图,或按Cmd+Shift+4进行矩形选择。如果不起作用,则必须检查System Preferences > Keyboard > Shortcuts > Screenshots设置
Cmd+Shift+3
Cmd+Shift+4
System Preferences > Keyboard > Shortcuts > Screenshots
关于菜单问题,您可以随时替换整个菜单。这里是a tutorial。请注意,第一个菜单将始终保持不变,因为它不属于应用程序,而是属于系统
以下是本教程的副本:
from Tkinter import * def donothing(): filewin = Toplevel(root) button = Button(filewin, text="Do nothing button") button.pack() root = Tk() menubar = Menu(root) filemenu = Menu(menubar, tearoff=0) filemenu.add_command(label="New", command=donothing) filemenu.add_command(label="Open", command=donothing) filemenu.add_command(label="Save", command=donothing) filemenu.add_command(label="Save as...", command=donothing) filemenu.add_command(label="Close", command=donothing) filemenu.add_separator() filemenu.add_command(label="Exit", command=root.quit) menubar.add_cascade(label="File", menu=filemenu) editmenu = Menu(menubar, tearoff=0) editmenu.add_command(label="Undo", command=donothing) editmenu.add_separator() editmenu.add_command(label="Cut", command=donothing) editmenu.add_command(label="Copy", command=donothing) editmenu.add_command(label="Paste", command=donothing) editmenu.add_command(label="Delete", command=donothing) editmenu.add_command(label="Select All", command=donothing) menubar.add_cascade(label="Edit", menu=editmenu) helpmenu = Menu(menubar, tearoff=0) helpmenu.add_command(label="Help Index", command=donothing) helpmenu.add_command(label="About...", command=donothing) menubar.add_cascade(label="Help", menu=helpmenu) root.config(menu=menubar) root.mainloop()
遗憾的是,我没有足够的声誉发表评论。回答您的子问题:您可以按
Cmd+Shift+3
进行全屏截图,或按Cmd+Shift+4
进行矩形选择。如果不起作用,则必须检查System Preferences > Keyboard > Shortcuts > Screenshots
设置关于菜单问题,您可以随时替换整个菜单。这里是a tutorial。请注意,第一个菜单将始终保持不变,因为它不属于应用程序,而是属于系统
以下是本教程的副本:
相关问题 更多 >
编程相关推荐