tkraise oddity

Eric Brunel eric_brunel at despammed.com
Wed Aug 24 18:00:34 CEST 2005


On 24 Aug 2005 06:57:07 -0700, twd <twd_gg at dockerz.net> wrote:

> I'm seeing some new and unexpected behaviour with tkinter + python2.4,
> in a gnome+linux environment. The code below used to work (and
> continues to work under windows). The intended behaviour is that a
> window is created the the first time the button is pushed, and then
> de-iconified and brought to the top whenever the button is pushed
> again. The behaviour I'm seeing is that the window is de-iconified (if
> iconified) correctly, but if already present on the screen, it is not
> raised.

What exactly do you expect? Do you want to raise the window above all other windows *in your application*, or above *all* other windows? I doubt tk can guarantee the latter, and this seems to be confirmed by the manuel for tk's raise command; cf. http://www.tcl.tk/man/tcl8.4/TkCmd/raise.htm

If you put the window with the button in front of the window with the label, and if pressing the button doesn't bring the window with the lable above the other, then it may be a bug. If it works, I guess it's just a matter of how the window managers interpret what "raising a window" means... But I'm no specialist here, so maybe someone else will confirm that.

[snip]
> from Tkinter import *
>
> t = None
>
> def cmd():
>     global t
>     if t:
>         t.tkraise()
>         t.deiconify()
>     else:
>         t = Toplevel()
>         l = Label( t, text=".... some text goes here ..." )
>         l.pack()
>
> b =  Button(text="Raise",command=cmd)
> b.pack()
> b.mainloop()

(BTW, did you try to put the deiconify before the tkraise?)

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17;8(%,5.Z65\'*9--56l7+-'])"



More information about the Python-list mailing list