I am trying to justify the text from tkinter text. The other answers (How to set justification on Tkinter Text box)said that it is my answer. I am try to use this code (I am using tkinter 8.6 and Python 3):
import tkinter
root = tkinter.Tk()
text_widget = tkinter.Text()
text_widget.pack(fill='both', expand=True)
text_widget.tag_configure('tag-center', justify='justify')
text_widget.insert('end', 'text ' * 10, 'tag-center')
but then, if I run the code:
Traceback (most recent call last):
File "C:/Users/moon/AppData/Local/Programs/Python/Python310/asking1.py", line 5, in <module>
text_widget.tag_configure('tag-center', justify='justify')
File "C:\Users\moon\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 3888, in tag_configure
return self._configure(('tag', 'configure', tagName), cnf, kw)
File "C:\Users\moon\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1665, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: bad justification "justify": must be left, right, or center
It said "_tkinter.TclError: bad justification "justify": must be left, right, or center, but no justify. I saw it that both MS Word and LO Writer has Justify. How to do it? Thank you!