我在ttk标签中有一个由多行组成的文本。默认情况下,文本从左边框到右边框显示,没有任何“对齐”选项。我的目标是在所有的标签上传播文字。我不想让文本右对齐、左对齐、居中对齐,等等。我想证明它,特别是当你在Microsoft Word中对齐一个文本时。我怎样才能达到我的目标?
发布于 2020-05-29 16:49:00
您可以使用tkinter.ScrolledText模块:
from tkinter import *
from tkinter.scrolledtext import *
win = Tk()
TEXT="""I have a text composed by multiple lines in a ttk label.
by default the text is displayed from the left border to right one without any kind of "justify" option.
My goal is spread the text on all the label. I don't want to align the text on the right, on the left, on the center, etc..
I want to justify it, exatly when you justify a text in Microsoft Word. how can I reach my goal?"""
text = ScrolledText(win, width=80, height=41, wrap=WORD) # create text zone
text.pack(expand=True, fill=BOTH) # pack it in the entire window
text.insert(1.0, TEXT)
win.mainloop()通过添加tkinter.filedialog,你可以制作一个真正的记事本!
Python就是这样制作的。
https://stackoverflow.com/questions/62033360
复制相似问题