[Tutor] How to get the width of teh button widget..??
Michael Lange
klappnase at freenet.de
Sat Oct 21 00:22:35 CEST 2006
On Fri, 20 Oct 2006 11:55:10 +0100
"Asrarahmed Kadri" <ajkadri at googlemail.com> wrote:
> Folks,
>
> 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..
>
Hi Asrarahmed,
in case you use Tkinter, something like this should do the trick (untested):
b1 = Button(master, text='Hi')
b1.grid(row=0, column=0, sticky='ew')
b2 = Button(master, text='Good-bye')
b2.grid(row=0, column=1, sticky='ew')
maxwidth = 0
for button in (b1, b2):
w = button.winfo_reqwidth()
if w > maxwidth:
maxwidth = w
master.grid_columnconfigure(0, minsize=maxwidth)
master.grid_columnconfigure(1, minsize=maxwidth)
or, if this is an option for you, use a Pmw.ButtonBox and call its alignbuttons() method.
I hope this helps
Michael
More information about the Tutor
mailing list