New Tkinter windows don't get focus on OS X
kw at codebykevin.com
Thu Sep 10 23:38:36 CEST 2009
> At first I was puzzled by this, because if you run something like
> "open -a TextEdit", TextEdit gets the focus. But then I realized this
> must be because of the "open" command. Indeed, if you try running
> something like "/Applications/MacPorts/Python\ 2.6/IDLE.app/Contents/
> MacOS/IDLE" focus will remain in Terminal.
> On the other hand, every other GUI toolkit I've used (e.g. wxPython,
> PyQt4, pyglet) does not have this problem. (If you try the basic
> example from http://www.wxpython.org/tut-part1.php you'll see what I
> mean.) How are these other toolkits able to steal the focus? More
> important, is it *possible* to have a Tkinter app steal the focus,
> even if it's not the default behavior?
I've confirmed this with wx...not sure why Tk behaves differently.
>> The way around this is to wrap your application up in a standard Mac app
>> bundle using py2app. The average Mac user isn't going to launch a
>> Python-based game from the command line.
> True, but it'll still be a lot less painful for me to test my app if I
> can get it to steal focus
> when launched from the command line. If anyone knows how to do this in
> Tkinter, help would be much appreciated.
I'm not sure there's a way to do this.
Code by Kevin
More information about the Python-list