Python tkinter Menu issue

I am experiencing a problem under Catalina while using Python 3.7.4 and 3.8.0.


I am trying to click on the menu but it is not responding to mouse clicks until I switch to another window and then come back to the python app.


You can see this by running the following code:


import tkinter as tk

root = tk.Tk()

root.mainloop()


I know this is minimal as a program, but it displays exactly what the issue is. Even with this minimal program you should still be able to click the 'python' menu next to the Apple icon on the menu and quit, but you cannot until you CMD+Tab/click out of the python window and then CMD+Tab/click back into the python window.


Is there something wrong between Catalina and Python? Any idea what I can do to fix this behavior?


My environment is macOS Catalina 10.15, Python 3.7.4 via pyEnv, and Visual Studio Code 1.39.2.


I have the same issue.

But I was able to shift focus to the python "window" by inserting this code:


from os import system
from platform import system as platform

if platform() == 'Darwin':
system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "python" to true' ''')

Where the if statement is placed in the section of code where your tk.Frame of Window is generated. In my case it is placed in the class that generates the stacked frames used in my application.

But the widowing focus issue remains the same for the top-level menubar. It is not clickable until focus is moved from my app, and refocusing on my app.


Python tkinter Menu issue
 
 
Q