I'm missing something about tkinter updates. How can I give tkinter a chance to run?

Here's some code:

import time
import tkinter
import tkinter.scrolledtext

tk = tkinter.Tk()
f = tkinter.Toplevel(tk)
st = tkinter.scrolledtext.ScrolledText(f)
st.pack()



def update():
    print('updating')
    st.see(tkinter.END)
    tk.after(1000, update)


input('hit enter to start')
update()
f = open('/etc/services')

for line in f:
  st.insert(tkinter.END, line + '\n')
  print('got it')
  #time.sleep(5)
  input('more?')

input('finished?')




When I do this (input('more?'), it works as expected. If I comment that line out, then the program reads the entire file, then update the window right at the end, even if I put a sleep in there. What can I do inside the loop to give tk a chance?

Thanks.

--
Yves.                                                  http://www.SollerS.ca/
                                                       http://ipv6.SollerS.ca
                                                       http://blog.zioup.org/
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to