I'm working with tkinter on Python 3.4.1 (Windows 7), and I'm finding that ttk's Entry.xview_moveto function is not working properly. Here is some 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 the text all the way to the left, but it doesn't. However, I noticed that if I use
b.after(500, b.xview_moveto, 1)
it works just fine. Why do I have to delay the function call in order for it to work properly? Am I doing something wrong?
Update: In addition to fhdrsdg's solution, I have found that the Entry.after_idle
method works for my program. It does not seem to work for the above simple example, but if anybody else has the same problem as me, this could be another, cleaner-looking solution.