Making a Label that looks the same as a button.
Eric Brunel
eric_brunel at despammed.com
Tue Jun 13 09:38:20 EDT 2006
On 13 Jun 2006 06:14:03 -0700, Dustan <DustanGroups at gmail.com> wrote:
> I have a Button object that gets replaced by a Label when clicked.
>
> Button(buttonsframe,text=' ',command=c,font=buttonsFont)
> Note that the text is a single space. buttonsFont uses 'Courier New' as
> a family.
>
> When clicked, the Button is destroyed and replaced with a Label object:
> Label(buttonsframe,text=x,font=buttonsFont,relief=RAISED)
>
> The intent is for the Label object to look identical to the button
> object, except for the non-space character x. The Label object is a
> little smaller than the Button object. When I set borderwidth, the
> label object does increase in size, but that's not going to make it
> look the same, since it makes the border thicker.
>
> How do I get the Label object to look just like the Button object?
There is least two other options that are different for Labels and Buttons:
>>> b = Button(root)
>>> b.cget('padx')
'3m'
>>> b.cget('pady')
'1m'
>>> l = Label(root)
>>> l.cget('padx')
'1'
>>> l.cget('pady')
'1'
The padx and pady are the distance between the text and the widget
borders. They are larger on a Button.
BTW, you can get all configuration options for any widget with:
for k in widget.configure().keys():
print k, ':', widget.cget(k)
So you can easily compare common options between a standard Label and a
standard Button.
HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
More information about the Python-list
mailing list