adding a new line of text in Tk

Ben Cartwright bencvt at gmail.com
Sun Mar 26 03:11:08 EST 2006


nigel wrote:
> w =Label(root, text="Congratulations you have made it this far,just a few more
> questions then i will be asking you some")
>
> The problem i have is where i have started to write some text"Congratulations
> you have made it this far,just a few more questions then i will be asking you
> some")
> I would actually like to add some text but it puts it all on one line.I would
> like to be able to tell it to start a new line.


Just use \n in your string, e.g.:

w = Label(root, text="Line 1\nLine 2\nLine 3")

Or a triple-quoted string will do the trick:

w = Label(root, text="""Line 1
Line 2
Line 3""")

--Ben




More information about the Python-list mailing list