tkraise oddity

T

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

Eric Brunel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,315
Members
47,996
Latest member
LaurenFola

Latest Threads

Top