简体   繁体   English

在Tkinter中单击按钮或复选框时,如何扩展窗口/框架?

[英]How to expand window/frame when button or checkbox is clicked in tkinter?

I am using Tkinter for my python script. 我将Tkinter用于我的python脚本。 At current stage, gui looks ugly because of too many options/widgets in one screen. 在当前阶段,由于一个屏幕中的选项/小工具太多,gui看起来很丑。 Not all of them are needed all the time and it can be divided into four parts. 并非一直都需要它们,它可以分为四个部分。 Hence my idea is to have them expand the frame (one frame for each part) with its options/widgets in the current window. 因此,我的想法是让它们在当前窗口中使用其选项/小部件扩展框架(每个零件一个框架)。

Is it possible in tkinter to expand the window/frame when a button or a checkbox is clicked? 单击按钮或复选框时tkinter中是否可以展开窗口/框架?

ps - I have tried opening each part in new window but this makes gui unnecessarily complicated. ps-我已经尝试在新窗口中打开每个零件,但这使gui不必要地变得复杂。

Thanks! 谢谢!

So, your gonna need to define what happens when the button is clicked- 因此,您需要定义单击按钮时会发生什么-

def buttonClicked():
    root.geometry("350x300")

where root is the window and then on the button you will need to write - root是窗口,然后在按钮上您需要编写-

btn = tkinter.Button(text = "Button", command=buttonClicked)
btn.pack

Hope that answers your question! 希望这能回答你的问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM