gert wrote:
After reading the docs and seeing a few examples i think this should
work ?
Am I forgetting something here or am I doing something stupid ?
Anyway I see my yellow screen, that has to count for something :)

Try this:
# tdh_show.py
from __future__ import with_statement

import time
import Tkinter
import Tkconstants as TK
import threading

class Weegbrug(threading.Thread):
    def __init__(self, frame, var, filename):
        self.frame = frame
        self.var = var
        self.filename = filename
        threading.Thread.__init__(self)

    def run(self):
        with open(self.filename, 'r') as f:
            for n, line in enumerate(f):
                # the tricky bit:
                self.frame.after(100, self.var.set, line.strip())
                time.sleep(.5)


def main(filename):
    root = Tkinter.Tk()
    svar = Tkinter.StringVar(root)
    frame = Tkinter.Frame(root, relief=TK.RIDGE, borderwidth=2)
    frame.pack(fill=TK.BOTH, expand=1)
    label = Tkinter.Label(frame, textvar=svar, bg='yellow',
                          font=('Helvetica', 16))
    label.pack(fill=TK.X, expand=1)
    button = Tkinter.Button(frame, text="Exit", command=root.destroy)
    button.pack(side=TK.BOTTOM)
    reader = Weegbrug(frame, svar, filename)
    button = Tkinter.Button(frame, text="Go", command=reader.start)
    button.pack(side=TK.BOTTOM)
    root.mainloop()


if __name__ == '__main__':
    main(__file__)


--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to