Answer a question

I am doing a simple project in school and I need to make six different buttons to click on. The buttons must have different sizes, but I can't find how do do it. I have made the button by using:

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)

I imagine that something like:

self.button1.size(height=100, width=100)

would work, but it doesn't and I cannot find how to do it anywhere.

I am using Python 3.3.

Answers

Configuring a button (or any widget) in Tkinter is done by calling a configure method "config"

To change the size of a button called button1 you simple call

button1.config( height = WHATEVER, width = WHATEVER2 )

If you know what size you want at initialization these options can be added to the constructor.

button1 = Button(self, text = "Send", command = self.response1, height = 100, width = 100) 
Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐