[Tutor] How to get the width of teh button widget..??

Alan Gauld alan.gauld at btinternet.com
Sat Oct 21 00:43:33 CEST 2006

"Asrarahmed Kadri" <ajkadri at googlemail.com> wrote

> Sorry for asking you such a trivial question.!!! But i want to size 
> up all
> the buttons with the same size as the largest one in the interface.. 
> And
> thats why I am asking this question..

Assuming you mean in Tkinter(given yor other posts) it depends...
You can specify the size when you create it, and if you use the
placer layout manager it should keep that size.

But if you use grid or packer managers then the size may change
if the window is resized, depending on the options.

However you should be able to read the size of the buttons back
from the widget at runtime using dictionary syntax:

def max(a,b): return (a>b) and a or b

for button in mybuttons:
    max_size = max(max_size, button['width'])

Or something very similar...

Alan G. 

More information about the Tutor mailing list