Ham*_*FzM 5 python text tkinter python-3.x
我正在使用 RTL 语言,我需要我的文本是 RTL。有没有办法做到这一点?我怎样才能证明我的文字是合理的?例子:
from tkinter import *
from tkinter.constants import *
root = Tk()
text = Text(root,,font=('Tahoma',8))#I need RTL and Right justified text!
text.grid()
scrl = Scrollbar(root, command=text.yview)
text.config(yscrollcommand=scrl.set)
scrl.grid(row=0, column=1, sticky='ns')
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
小智 2
我修改了你的代码,它成功了!...
from tkinter import *
from tkinter.constants import *
root = Tk()
text = Text(root,,font=('Tahoma',8))#I need RTL and Right justified text!
text.tag_configure('tag-right', justify='right')
text.insert('end', 'text ' * 10, 'tag-right')
text.grid()
scrl = Scrollbar(root, command=text.yview)
text.config(yscrollcommand=scrl.set)
scrl.grid(row=0, column=1, sticky='ns')
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
事实上,我添加了两行代码,justify=CENTER
为Text
小部件设置失败:小部件没有这样的选项。
您想要的是使用参数创建一个标签justify
。然后您可以使用该标签插入一些文本(或者您可以插入任何文本,然后将标签应用到特定区域)...祝您好运!:)