在 Tkinter 中调整框架大小
我一直在用 python 中的 Tkinter 模块制作一个小程序,我想知道是否可以用鼠标调整程序中的框架大小。例如,用户可以拖动框架边框,它会自行调整大小。
I have been making a small program with the Tkinter module in python, and I was wondering whether it was possible or not to resize a frame in my program with the mouse. As in, the user can drag the frame border and it will resize itself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的术语使问题不清楚。用户可以调整大小的窗口称为顶级窗口。这些在显示屏上显示为矩形窗口,周围有一个框架(通常是标题栏)以及可以抓取和调整大小的边缘或角落。
术语 Frame 指的是必须位于顶级或其子级之一内的容器小部件。框架可以调整大小,但您必须编写代码才能以交互方式调整它们的大小。例如,您可以在一个或多个角落放置一个小抓握小部件,并编写对鼠标按钮的按下、移动和释放的绑定。
根据您正在寻找的效果,您可能需要一个 PanedWindow,它是一个包含窗框可让您调整其他两个小部件之间的空间比例。
Your use of terminology makes the question unclear. Windows which may be resized by the user are called Toplevel windows. These are what appear as rectangular windows on the display, with a frame around them, typically a title bar, and edges or corners that can be grabbed and resized.
The term Frame refers to a container widget that must be inside a Toplevel or one of its descendents. A Frame has the ability to be resized but you have to write the code to let you interactively resize them. For example, you could place a little grip widget in one or more corners, and writing bindings to the press, motion and release of a mouse button.
Depending on the effect you are looking for, you might want a PanedWindow which is a container that includes a sash that lets you adjust the proportion of space between two other widgets.