条目小部件对齐 - 文本比小部件长 [英] Entry Widget Justification - text longer than widget

查看:39
本文介绍了条目小部件对齐 - 文本比小部件长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个宽度为 60 个字符的条目小部件.小部件是右对齐的.当与条目小部件关联的文本变量包含少于 60 个字符时,条目小部件显示右对齐的文本.当 textvariable 超过 60 个字符时,文本左对齐.我无法从开始之前的位置插入文本,即-34,所以这是不可能实现的吗?

I have an entry widget with a width of 60 chars. The widget is right justified. When the textvariable associated with the entry widget contains less than 60 chars, the entry widget shows the text right justified. When the textvariable is longer than 60 characters the text is left justified. I cannot insert the text from a position before the start, i.e. -34, so is this impossible to achieve?

我希望能够显示比条目小部件长的文本结尾.

I want to be able to display the end of the text if it's longer than the entry widget.

self.infile_var = tk.StringVar()
self.infile_e = tk.Entry(self.infile_lf,
                         textvariable=self.infile_var,
                         justify='right',
                         bd =2)

推荐答案

我不太明白您希望在开始前的位置插入——这没有任何意义.但是,如果您只想让最右边的字符可见,您可以使用 xview_moveto 方法.

I don't quite understand your desire to insert at a position before the start -- that doesn't make any sense. However, if all you want is for the right-most characters to be visible you can use the xview_moveto method.

self.infile_e.xview_moveto(1.0)

这篇关于条目小部件对齐 - 文本比小部件长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆