Making a Label that looks the same as a button.

2006-06-13 Thread 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?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a Label that looks the same as a button.

2006-06-13 Thread Eric Brunel
On 13 Jun 2006 06:14:03 -0700, Dustan [EMAIL PROTECTED] 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+-'])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a Label that looks the same as a button.

2006-06-13 Thread Andrew Gwozdziewycz
It's imperative that you explain which toolkit you are using since  
they all have differences.

On Jun 13, 2006, at 9:14 AM, Dustan 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?

 -- 
 http://mail.python.org/mailman/listinfo/python-list

---
Andrew Gwozdziewycz
[EMAIL PROTECTED]
http://23excuses.com | http://ihadagreatview.org | http://and.rovir.us


-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Making a Label that looks the same as a button.

2006-06-13 Thread Grayson, John
 


Buttons can look like labels without the need to create another object -
just remove the
Command binding, set state to DISABLED and disabledforeground='same
color as NORMAL'...

This demonstrates how to play with button styles:

import Tkinter as tk

class GUI:
def __init__(self):
self.root = tk.Tk()
self.root.title('Button Styles')
for bdw in range(5):
setattr(self, 'of%d' % bdw, tk.Frame(self.root,
borderwidth=0))
tk.Label(getattr(self, 'of%d' % bdw),
  text='borderwidth = %d  ' % bdw).pack(side=tk.LEFT)
for relief in [tk.RAISED, tk.SUNKEN, tk.FLAT, tk.RIDGE,
tk.GROOVE, tk.SOLID]:
tk.Button(getattr(self, 'of%d' % bdw), text=relief,
borderwidth=bdw,
   relief=relief, width=10,
   command=lambda s=self, r=relief, b=bdw:
s.prt(r,b))\
  .pack(side=tk.LEFT, padx=7-bdw, pady=7-bdw)
getattr(self, 'of%d' % bdw).pack()

def prt(self, relief, border):
print '%s:%d' % (relief, border)

myGUI = GUI()
myGUI.root.mainloop()




John Grayson

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Dustan
Sent: Tuesday, June 13, 2006 9:14 AM
To: python-list@python.org
Subject: Making a Label that looks the same as a button.

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?

--
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a Label that looks the same as a button.

2006-06-13 Thread Cameron Laird
In article [EMAIL PROTECTED],
Grayson, John [EMAIL PROTECTED] wrote:
 


Buttons can look like labels without the need to create another object -
just remove the
Command binding, set state to DISABLED and disabledforeground='same
color as NORMAL'...

This demonstrates how to play with button styles:
.
.
.
John, as I read the original poster, Tkinter.DISABLED is *exactly* 
what he wants (although he might not realize it yet); I suspect
there's no need at all for other styling.

Are Button and Label styles truly identical except for
disabledforeground?  While I can't make the time now to research
this for myself, it surprises me; I thought there were padding
differences ...

Your remark about the Command has me curious:  why remove it?  In
terms of the original poster's description, what does this serve?
I repeat my speculation that Tkinter.DISABLED will do it all for
him.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a Label that looks the same as a button.

2006-06-13 Thread Fredrik Lundh
Andrew Gwozdziewycz wrote:

 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

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making a Label that looks the same as a button.

2006-06-13 Thread Dustan

Cameron Laird wrote:
 In article [EMAIL PROTECTED],
 Grayson, John [EMAIL PROTECTED] wrote:
 
 
 
 Buttons can look like labels without the need to create another object -
 just remove the
 Command binding, set state to DISABLED and disabledforeground='same
 color as NORMAL'...
 
 This demonstrates how to play with button styles:
   .
   .
   .
 John, as I read the original poster, Tkinter.DISABLED is *exactly*
 what he wants (although he might not realize it yet); I suspect
 there's no need at all for other styling.

 Are Button and Label styles truly identical except for
 disabledforeground?  While I can't make the time now to research
 this for myself, it surprises me; I thought there were padding
 differences ...

 Your remark about the Command has me curious:  why remove it?  In
 terms of the original poster's description, what does this serve?
 I repeat my speculation that Tkinter.DISABLED will do it all for
 him.

Yes, that's what I needed (and I knew about that before), but I didn't
know about the disabledforeground option. Thanks for the information;
it worked nicely.

-- 
http://mail.python.org/mailman/listinfo/python-list