[Tkinter-discuss] question on displaying inserted text in widget 'Text'

V H haofast2006 at hotmail.com
Fri Mar 17 17:40:06 CET 2006


Hello,

The function what I implemented takes 30 seconds. Before running it I want 
to give some message to user by displaying them in the widget 'Text'. Seems 
it's not useful because the message are always displayed after the excution. 
Could you help me to resolve it? Thanks a lot.

best regards,
Weining

The sample file is as following:

from Tkinter import *
import time

class one:
  def __init__(self, master):
    self.text=None
    frame = Frame(master)
    button = Button(tk,text='start', command=self.execute)
    button.pack()
    self.text = Text(frame,width=30,height=10)
    self.text.pack()
    frame.pack()

  def addMessage(self,message):
    self.text.insert(END,self.getCurrentTime())
    self.text.insert(END,message)
    self.text.insert(END, '\n')

  def getCurrentTime(self):
    now = time.localtime(time.time())
    year, month, day, hour, minute, second, weekday, yearday, daylight = now
    return "%02d:%02d:%02d" % (hour, minute, second)

  def execute(self):
    self.addMessage(' Start testing')
    for i in range(10000):
        for j in range (2000):
            i*j
    self.addMessage(' Finish testing')

tk = Tk()
o = one(tk)
tk.mainloop()

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



More information about the Tkinter-discuss mailing list