Tcl/Tk:最大化窗口/确定窗口是否最大化?

发布于 2024-09-13 02:54:16 字数 210 浏览 1 评论 0原文

我能否查明我的顶层窗口是否已最大化,以及是否可以通过编程方式将其最大化?我在 Windows XP 上使用 R 的 tcltk 包 8.5。

问题的原因是:我想通过先调用撤回然后取消图标来强制 事件。但是,如果窗口在这两个函数调用之前最大化,则在这两个函数调用之后窗口不会最大化。有没有更简单的方法来执行该事件?

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 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谷夏 2024-09-20 02:54:16

您可以通过 wm state $toplevel 发现窗口是否最大化(查找 zoomed 作为返回值)。但是……

操作系统无法在 Windows 上正确生成 事件;你只能在被映射的窗口上获得它们,这是微妙的不同。 (与 X 相比,Windows 告诉您的有关堆栈顺序及其后果的信息要少得多;Tk 非常接近 X 的模型。)不过,您没有说明为什么想要此事件;也许还有其他东西可以满足您的真正目的?

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?

窝囊感情。 2024-09-20 02:54:16

编写了一个函数,将可见性事件传播到给定的小部件及其所有子部件。

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

这样,我不需要调用withdraw/deiconify并将我的事件发送到每个小部件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文