In a sense, a combination of various other methods found on the Internet, this works on OS X 10.11 and Python 3.5.1, running in Vienna, and should work on other platforms as well. In OS X, it also targets the application by process ID, not the name of the application.
from tkinter import Tk import os import subprocess import platform def raise_app(root: Tk): root.attributes("-topmost", True) if platform.system() == 'Darwin': tmpl = 'tell application "System Events" to set frontmost of every process whose unix id is {} to true' script = tmpl.format(os.getpid()) output = subprocess.check_call(['/usr/bin/osascript', '-e', script]) root.after(0, lambda: root.attributes("-topmost", False))
You call this right before calling mainloop() , for example:
raise_app(root) root.mainloop()
source share