[英]Tkinter Entry justify text right when text is larger than the box
I have some tk.Entry()s in my gui.我的 gui 中有一些 tk.Entry()。 The text inside the entries is always right-aligned.
条目中的文本始终是右对齐的。 But once the text is larger than the box, the text is left-aligned.
但是一旦文本大于框,文本就会左对齐。
Sample-Code:示例代码:
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()
The result:结果:
The first box is perfect.第一个盒子很完美。 Second box contains whole alphabet but it's left-aligned.
第二个框包含整个字母,但它是左对齐的。 I want that the second box looks like the third box even if it contains the entire alphabet,
我希望第二个框看起来像第三个框,即使它包含整个字母表,
Thanks for your help:)谢谢你的帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.