问题
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)
回答1:
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)
来源:https://stackoverflow.com/questions/30281302/entry-widget-justification-text-longer-than-widget