I am working with tkinter on Python 3.4.1 (Windows 7), and I found that the ttk Entry.xview_moveto function does not work correctly. Here is a simple code:
from tkinter import * from tkinter import ttk a = Tk() text = StringVar(a, value='qwertyuiopasdfghjklzxcvbnm1234567890') b = ttk.Entry(a, textvariable=text) b.grid() b.xview_moveto(1)
The xview_moveto function should scroll all the way to the left, but that is not the case. However, I noticed that if I use
b.after(500, b.xview_moveto, 1)
It works great. Why should I delay a function call so that it works correctly? Am I doing something wrong?
Update . In addition to the fhdrsdg solution, I found that the Entry.after_idle method works for my program. This doesn't seem to work for the above simple example, but if someone else has the same problem as me, it might be a different, cleaner solution.
source share