I have a 525x650 window geometry in tkinter. I want to display the list items in multiple spaces such that they cover all the space in width and move to next line as the width space is full. But instead, all items are getting printed on a single line. When I use the code to print each item in a new line, it exceed the height of the main window.
def throat_symp():
#empty_label.config(text=(throat_symplist)) #For printing on same line
empty_label.config(text=("\n".join(throat_symplist))) enter image description here #For printing on seperate line
print(throat_symplist)
You can configure your Label with wraplength=525
to tell it to word-wrap the text at the given width.
Or, instead of a Label, you can use a Text (with state=DISABLED to prevent editing); this will automatically wrap at the widget's width, and is much easier to add scrolling if the list is still too tall to fit in the window.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.