Python 3 Tkinter: as text to text in Tkinter text

How do you wrap text as a Tkinter widget Text? wraplengthaccepts only screen units, not a parameter WORD.

+4
source share
1 answer

Use option wrap=WORD. Here is an example:

from tkinter import *

root = Tk()
t = Text(wrap=WORD)
t.pack()
root.mainloop()

Alternatively, you can set the value for wrapwith Text.config():

t = Text()
t.config(wrap=WORD)

Other valid values ​​for wrapare CHAR, which is the default value, or NONE, in which case the wrap does not occur, and the line will grow indefinitely.

+7
source

Source: https://habr.com/ru/post/1607385/


All Articles