在另一个内部绘制一个窗口 [英] draw a window inside another

查看:34
本文介绍了在另一个内部绘制一个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下是否可以在父窗口内绘制一个子窗口,以便它只能在父窗口内移动而不能移出父窗口边界.

I wanted to ask if it is possible to draw a child window inside a parent window so that it will only be able to move inside the parent window and won't be able to move out of the parent window bounds.

推荐答案

如果您的意思是在父窗口内拥有带有标题栏、菜单、状态栏等的实际窗口,那么答案是:不,Tcl/Tk 和扩展 Tkinter 不支持它的标准小部件.

If you mean having actual windows with title bar, menu, status bar etc. inside the parent window then the answer is: No, Tcl/Tk and by extension Tkinter does not support this with its standard widgets.

过去一直在努力实现模拟 MDI 的小部件,如您在 TCL wiki,但他们中的大多数已经有十多年的历史了.如果您确实需要实现这种 UI 设计,您可能需要自己实现它或选择不同的 GUI 工具包.

There have been efforts in the past to implement widgets which emulate MDI as you can see on the TCL wiki, but most of them are over a decade old. You will probably have to implement it yourself or choose a different GUI toolkit if you really need to implement this kind of UI design.

如果你自己做,你可以使用Frame小部件作为子窗口,并使用place把它放在包含窗口中.或者,您可以将其创建为画布上的对象.您必须编写所有代码来提供内部窗口边框和标题栏,并管理它的移动、图标化等.

If you do it yourself, you can use the Frame widget as the subwindow, and use place to put it in the containing window. Or, you can create it as an object on a canvas. You'll have to write all of the code to give the inner window borders and a title bar, and to manage moving it around, iconifying it, etc.

这篇关于在另一个内部绘制一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆