Tcl/Tk: Maximize window / determine if window is maximized?
Can I find out if my toplevel window is maximized, and can I maximize it programmatically? I am using R's tcltk package 8.5 on Windows XP.
The reason for the question is: I want to enforce a <Visibility>
event by 开发者_JS百科calling first withdraw and then deiconify. However, if the window was maximized before these two function calls, it is not after these calls. Is there an easier way to enforce the event?
You can discover the whether the window is maximized with wm state $toplevel
(look for zoomed
as a return value). But…
The OS doesn't generate <Visibility>
events properly for you on Windows; you only get them on the window being mapped, and that's subtly different. (Windows tells you much less about the stacking order and its consequences than X does; Tk's pretty close to X's model.) You don't say why you want this event though; perhaps there's something else that will serve your real purpose?
Wrote a function that propagates the Visibility event to a given widget and all its children.
tkevent.propagate <- function(w,e) {
tkevent.generate(w, e)
children <- as.character(tkwinfo("children", w))
if(length(children)>0) lapply(children, function(c) tkevent.propagate(c,e))
}
This way, I don't need to call withdraw/deiconify and get my event to each widget.
精彩评论