The program below creates a window that contains a button. When the button is clicked, the window is iconified (minimized). After 3000 milliseconds, the window is supposed to deiconify and raise itself above all other windows. When I run the program in the GNOME desktop environment using wish mywindow.tk
, the window iconifies as expected when the button is clicked. However, it does not deiconify and does not raise itself above all other windows after 3 seconds. There are no error messages.
proc doSomething {} {
wm iconify .
after 3000 {
wm deiconify .
raise .
}
}
button .mybutton -text "Click me" -command doSomething
grid .mybutton
What is the cause of the problem? How do I deiconify a window in Tk and raise it above all others when using the GNOME desktop environment?
- Tcl/Tk version: 8.6.13
- GNOME Shell version: 43.6
- I am using GNOME on Xorg instead of GNOME on Wayland.
- OS: Debian 12 bookworm
2
Answers
I managed to deiconify and raise the window above all others by withdrawing the window right before deiconifying it:
According to the Tk documentation for
wm wihdraw
:There isn’t anything you can do about it. Tk does window deiconifying and raising (of
toplevel
s) by asking the window manager to do it, but the window manager is entitled to ignore the request. The low-level API for that works that way, and window managers often prefer to ignore requests that they don’t believe correspond directly to real user activity.Internal Tk widgets can be directly restacked; Tk always handles those calls itself.
Sorry about that. This isn’t a Tk problem as such, but rather window manager policy.