The Label
widget doesn't line-wrap. The Message
widget will line-wrap text, but forces it to be roughly square. Here's an example:
from Tkinter import * root = Tk() root.title("hello") Message(root, text=48*'xxxxx ').grid(row=0, column=0, columnspan=3) Label(root, text='Name:').grid(row=1, column=0) Entry(root, width=50).grid(row=1, column=1) Button(root, text="?").grid(row=1, column=2) Button(root, text="Left").grid(row=2, column=0) Button(root, text="Center").grid(row=2, column=1) Button(root, text="Right").grid(row=2, column=2) root.mainloop()
I know that I can use aspect=700
to change the shape, but hard-coding numbers like that is what I'm trying to avoid.
The Tkinter Label
widget does wrap. It is just that the default setting is no wrapping. To get the text on one to wrap set the wraplength
parameter, the units for this are screen units so try wraplength=50
and adjust as necessary. You will also need to set justify
to LEFT
, RIGHT
, or CENTER
.
welcomenote = Label(root, text="Your long text", font="helvetica 14", wraplength=300, justify="center") welcomenote.pack()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With