2

I am trying to build an application with tkinter. I am using Mac OS Big Sur and I struggle a little bit with tkinter menus.

enter image description here (How do you do screenshots when you want to see the open menubar Haha)

It is no problem to add menu items to that default mac menubar but I want to delete some useless ones. I saw that you can customize the "Preferences" item with this command. root.createcommand('tk::mac::ShowPreferences', showMyPreferencesDialog) But I could not find anything else. Is this possible?

1
  • On Linux I create screenshots with tool which has time option - so I can set 5 seconds to screenshot and I have time to open menu or move mouse to display popup window. Commented Jul 10, 2021 at 20:30

1 Answer 1

3

Sadly, I don't have enough reputation to place a comment. Answering your subquestion: you can do screenshots by pressing Cmd+Shift+3 for fullscreen, or Cmd+Shift+4 for a rectangular selection. If that does not work, you have to check your System Preferences > Keyboard > Shortcuts > Screenshots setting.

Regarding your menu question, you can always replace the whole menu. Here is a tutorial. Though note, the first menu will always stay the same because it does not belong to the app but the system.

Here is a copy of the 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() 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.