Question

I have a line of text that I want to make look better by cutting off the end and printing it to the next line. I am using Tkinter and trying to make a Label use 3 lines instead of 1 as the text is WAY too long to display.

label4Text.set("0.0.0.0 This subnet mask is non-routable as there is no network portion")

It looks like this:

[0.0.0.0 This subnet mask is non-routable as there is no network portion]

I want it to look like this:

[0.0.0.0

This subnet mask is non-routable

There is no network portion]

How can this be achieved?

Was it helpful?

Solution

Use \n, like:

label4Text.set("0.0.0.0\nThis subnet mask is non-routable\nas there is no network portion")

Demo:

In [4]: s = "0.0.0.0 \nThis subnet mask is non-routable\nThere is no network portion"

In [5]: print s
0.0.0.0 
This subnet mask is non-routable
There is no network portion
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top