Skip to content

Commit a8a896c

Browse files
author
James Addison
authored
Merge pull request lyft#39 from mwpeterson/darwin-focus-fix
darwin focus fix
2 parents ba328f8 + e336c07 commit a8a896c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

blessclient/tokengui.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import
22
import platform
33
import os
4+
import subprocess
45
from six.moves.tkinter import Tk, Label, Entry, Button, ACTIVE, W, mainloop
56

67

@@ -35,7 +36,10 @@ def doGUI(self, hostname=None):
3536

3637
if platform.system() == 'Darwin':
3738
# Hack to get the GUI dialog focused in OSX
38-
os.system('/usr/bin/osascript -e \'tell app "Finder" to set frontmost of process "python" to true\'')
39+
# https://stackoverflow.com/questions/1892339/how-to-make-a-tkinter-window-jump-to-the-front/37235492#37235492
40+
tmpl = 'tell application "System Events" to set frontmost of every process whose unix id is {} to true'
41+
script = tmpl.format(os.getpid())
42+
subprocess.check_call(['/usr/bin/osascript', '-e', script])
3943

4044
mainloop()
4145

0 commit comments

Comments
 (0)