469,328 Members | 1,316 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

tkraise oddity

twd
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.

Does this code look ok? Any suggestions as to what the problem could
be?

Thanks for any pointers.

--------------------------------------------------
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()

Aug 24 '05 #1
1 2087
On 24 Aug 2005 06:57:07 -0700, twd <tw****@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+-'])"
Aug 24 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Michael Foord | last post: by
5 posts views Thread by jmdocherty | last post: by
43 posts views Thread by michael.f.ellis | last post: by
6 posts views Thread by Rex the Strange | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.