Force Focus in Tkinter

Steve Holden steve at holdenweb.com
Tue Dec 6 06:20:07 EST 2005


annagel wrote:
> I am looking for a way to force a Tkinter window into focus on a system
> level.  I know the force focus method should bring one window of my
> application into focus, but it seems I need to have some part of my
> application already in focus on a system level to make this work.  If
> for example I am entering text at the command line and call a
> force_focus on my root window the call will not return till I click on
> a window in my application.  The same goes for any modification to the
> main window I have tried adding new windows (toplevel), setting focus,
> generating events, none of these calls returns until I move focus over
> to my parrent window.  Is there any way around this?  Basically any way
> to create a kind of panic dialog that jumps up over what the user is
> doing at the command line.
> 
Before discussion *how* to do this, are you *really* sure you want to? I 
have always found it a freadful failing of the Windows interface that it 
can suddenly snatch the focus away from what I am doing and force my 
keystrokes and/or mouseclicks into another application.

It's worst when a dialog box appears just before I hit the ENTER key - 
the ENTER acts as a button press on the dialog's default button and I 
have no idea whether I just cancelled some actions or agreed to it.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list