Sch*_*mus 2 python tkinter tkinter-entry
我的 gui 中有一些 tk.Entry() 。条目内的文本始终右对齐。但一旦文本大于框,文本就会左对齐。
示例代码:
import tkinter as tk
root = tk.Tk()
small_text = "abc"
big_text = "abcdefghijklmnopqrstuvwxyz"
small_entry = tk.Entry(root, width=10, justify="right")
big_entry = tk.Entry(root, width=10, justify="right")
small_entry.insert(0, small_text)
big_entry.insert(0, big_text)
small_entry.pack()
big_entry.pack()
# what i want to see for big_entry:
wanna_see_text = "qrstuvwxyz"
wanna_see_entry = tk.Entry(root, width=10, justify="right")
wanna_see_entry.insert(0, wanna_see_text)
wanna_see_entry.pack()
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
结果:
第一个盒子就完美了 第二个框包含整个字母表,但它是左对齐的。我希望第二个盒子看起来像第三个盒子,即使它包含整个字母表,
感谢您的帮助 :)