This does not work for me. Can someone give me a clue?
Python 1.5.2b1 (#2, Jan 20 1999, 22:15:08) [GCC 2.7.2.1] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from Tkinter import *
>>> root = Tk()
>>> l = Label(root,text='left?',width=20,justify=LEFT)
>>> l.pack()
Everything works as expected except that the text gets centered
instead of being left justified...
Thanks, Frank
______________________________________________________________________________
"If I ever meet myself," said Zaphod, "I'll hit myself so hard I won't know
what's hit me."
-- Douglas Adams, 'The Restaurant at the End of the Universe'
I'm no Tk Guy, but the Tk docs clearly say "justify" affects what happens if
there's more than one line of text in the label. Change your text to e.g.
'left?\nright?\nin the middle?'
to see the effect.
Playing poke-and-hope with other options in the docs leads to this:
l = Label(root, text='left?', width=20, anchor='w')
l.pack()
That nails the label to the west edge of the root; where the label appears
within its parent, and how the text within the label is displayed, are
independent choices.
BTW, Guido's IDLE environment is great for playing with this stuff! Check
it out.
tkokly y'rs - tim
> This does not work for me. Can someone give me a clue?
> >>> l = Label(root,text='left?',width=20,justify=LEFT)
> Everything works as expected except that the text gets centered
> instead of being left justified...
As Tim said, 'justify' justifies multi-line text. But it affects the
relationship of one line to another, not the position of the text in
the container. See if this does what you want:
l = Label(root, text='left?', width=20, anchor='w')
or ... anchor=W) if you prefer. The value of anchor can be any of
eight compass points (N, NE, E ... ) or CENTER, either quoted or
capitalized with no quotes.
Hope this helps,
Matt Gushee
Oshamanbe, Hokkaido, Japan
> I'm no Tk Guy, but the Tk docs clearly say "justify" affects what happens if
^^^^^^^^^^^
> there's more than one line of text in the label. Change your text to e.g.
[snip]
Thanks for the help, it worked. BTW, you use the phrase 'the Tk docs',
what do you mean by that? I'm asking, because I've seen a lot of Tk docs,
but I couldn't consider any of those _the_ Tk docs. Fredrik's work looks
like a nice candidate for _the_ docs, any work being done on that?
Cheers, Frank
PS: I'd like to offer some help, but I'm just starting to lean Tkinter.
______________________________________________________________________________
Everything you see or hear or experience in any way at all is specific to you.
You create a universe by perceiving it, so everything in the universe you
perceive is specific to you.
-- Douglas Adams, 'Mostly Harmless'
> Tim Peters <tim...@email.msn.com> wrote:
>
> > I'm no Tk Guy, but the Tk docs clearly say "justify" affects what happens if
> ^^^^^^^^^^^
> > there's more than one line of text in the label. Change your text to e.g.
>
> [snip]
>
> Thanks for the help, it worked. BTW, you use the phrase 'the Tk docs',
> what do you mean by that? I'm asking, because I've seen a lot of Tk docs,
> but I couldn't consider any of those _the_ Tk docs. Fredrik's work looks
> like a nice candidate for _the_ docs, any work being done on that?
>
> Cheers, Frank
>
Go right to the Tk docs at Scriptics. These will get you started on what Tk
can do, and then you can map those options to Tkinter's options.
The Tkinter.py file is the second place to look, after the Tk docs.
http://www.scriptics.com/man/tcl8.0/contents.htm
Chad Netzer
The "take two" material:
http://www.pythonware.com/fredrik/tkdraft/index.htm
is about 80% finished (~150 pages if you print them).
but I'm afraid the remaining 20% will have to wait
until my Tkinter book is finished...
Cheers /F
http://www.pythonware.com/people/fredrik
The help file that came with the Tcl/Tk distribution.
overviews-are-for-wimps<wink>-ly y'rs - tim