我在学校做一个简单的项目,我需要点击六个不同的按钮.按钮必须有不同的大小,但我找不到怎么做.我使用以下方法制作了按钮:
def __init__(self, master):
super().__init__(master)
self.grid()
self.button1 = Button(self, text = "Send", command = self.response1)
self.button1.grid(row = 2, column = 0, sticky = W)
Run Code Online (Sandbox Code Playgroud)
我想像这样的东西:
self.button1.size(height=100, width=100)
Run Code Online (Sandbox Code Playgroud)
会工作,但它没有,我无法找到如何在任何地方做到这一点.
我使用的是Python 3.3.
cdb*_*sky 41
在Tkinter中配置按钮(或任何小部件)是通过调用configure方法 "config"来完成的
要更改名为button1的按钮的大小,您可以进行简单的调用
button1.config( height = WHATEVER, width = WHATEVER2 )
Run Code Online (Sandbox Code Playgroud)
如果您知道在启动时想要的大小,可以将这些选项添加到构造函数中.
button1 = Button(self, text = "Send", command = self.response1, height = 100, width = 100)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
90485 次 |
| 最近记录: |