Making a Label that looks the same as a button.

D

Dustan

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?
 
E

Eric Brunel

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:
'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
 
A

Andrew Gwozdziewycz

It's imperative that you explain which toolkit you are using since
they all have differences.
 
F

Fredrik Lundh

Andrew said:
It's imperative that you explain which toolkit you are using since
they all have differences.

however, if you knew the answer, you would have recognized what toolkit
he was using.

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top