Re: [Tutor] Tkinter: justify label

2005-07-20 Thread Bernard Lebel
Awesome, thanks a bunch!

Bernard


On 7/19/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Quoting Bernard Lebel [EMAIL PROTECTED]:
 
  Can you specify a justification for a label widget? I'm reading there
  is a justify option available on this page:
  http://www.pythonware.com/library/tkinter/introduction/x611-text-formatting.htm
  Although I don't know if this option works for label.
 
 It does; it just doesn't do what you think it does :-)
 
 justify is for multi-line labels.  If you are looking to position the text
 within the label, you need to use anchor.
 
 eg:
 
  from Tkinter import *
  tk = Tk()
  l1 = Label(tk, text='this is left\njustified', justify=LEFT)
  l1.pack()
  l2 = Label(tk, text='this, otoh, is right\njustified', justify=RIGHT)
  l2.pack()
  l3 = Label(tk, text='left aligned', anchor=W)
  l3.pack(fill=X)
  l4 = Label(tk, text='right aligned', anchor=E)
  l4.pack(fill=X)
 
 --
 John.
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter: justify label

2005-07-19 Thread jfouhy
Quoting Bernard Lebel [EMAIL PROTECTED]:

 Can you specify a justification for a label widget? I'm reading there
 is a justify option available on this page:
 http://www.pythonware.com/library/tkinter/introduction/x611-text-formatting.htm
 Although I don't know if this option works for label.

It does; it just doesn't do what you think it does :-)

justify is for multi-line labels.  If you are looking to position the text
within the label, you need to use anchor.

eg:

 from Tkinter import *
 tk = Tk()
 l1 = Label(tk, text='this is left\njustified', justify=LEFT)
 l1.pack()
 l2 = Label(tk, text='this, otoh, is right\njustified', justify=RIGHT)
 l2.pack()
 l3 = Label(tk, text='left aligned', anchor=W)
 l3.pack(fill=X)
 l4 = Label(tk, text='right aligned', anchor=E)
 l4.pack(fill=X)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor