Threading and tkinter

gert gert.cuykens at gmail.com
Tue Feb 17 11:55:13 EST 2009


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 :)

from tkinter import *
from threading import Thread

class Weegbrug(Thread):
    def __init__(self,v):
        self.v=v
        Thread.__init__(self)
    def run(self):
        while True:
            with open('com1','r') as f:
                 for line in f:
                     self.v.set(line[2:-1])

root = Tk()
v = StringVar()
v.set("00000")
w = Weegbrug(v)
w.start()
tx = Label(root, textvariable=v, width=800, height=600, bg="yellow",
font=("Helvetica", 300))
tx.pack(expand=YES, fill=BOTH)
root.title("Weegbrug")
root.overrideredirect(1)
root.geometry("%dx%d+0+0" % (root.winfo_screenwidth(),
root.winfo_screenheight()))
root.mainloop()



More information about the Python-list mailing list