[Tkinter-discuss] Need help on gui focus l

Michael Lange klappnase at web.de
Thu Oct 15 09:23:21 CEST 2009


Hi,

On Wed, 14 Oct 2009 17:07:30 -0300
Cam Farnell <msa01 at bitflipper.ca> wrote:

> The code given exhibits the problem on my Ubuntu Linux box. For the
> sake of clarity I enumerate three windows involved in this code:
> 
> - The MAIN window which has a button marked "popup" in it.
> - The CHILD windows which has a button marked "filedialog" in it.
> - The OPEN window which is the tkFileDialog
> 
> On my machine clicking on the "popup" and "filedialog" buttons works
> ok, but once you select a file and click OPEN, then what is on top
> and visible is the MAIN window whereas what the original poster
> wanted was to see the CHILD window. Even worse, if (starting from
> scratch again) you click the "popup" button, then drag the resulting
> CHILD window to a slightly new position then click the "filedialog"
> button, the OPEN window appears *under* the CHILD window which seems
> less than useful.
> 

You are right, this actually sounds less than useful and it is surely
not the way it is supposed to be. I cannot reproduce this here (debian
lenny, Python-2.5.2, Tk-8.4.19) though. I guess this is most likely a
bug in your version of Tk.
I wrote a tiny tcl script that does basically the same as the python
code from my last post, you can try if it exhibits the same bug, then
we could at least be sure that it's not python that causes the bug.

###CODE###
 #!/usr/bin/env wish

toplevel .t
wm withdraw .t
wm protocol .t WM_DELETE_WINDOW {wm withdraw .t}
button .t.b0 -text "filedialog" -command tk_getOpenFile
pack .t.b0 -padx 100 -pady 100
button .b1 -text "popup" -command {wm deiconify .t}
pack .b1 -padx 100 -pady 100
###CODE###

Michael



More information about the Tkinter-discuss mailing list