I am using PIL to make images that I need to display in a sequence. The image needs to change when a an event happens from a serial port.
I call the following function to display the image, but then the application is waiting for an event. I need to return to the main code which is sending commands to a serial port and waiting for data to return then displaying the next chart. def display(R,G,B): img = Image.new('RGB',(1000,1000),(24,24,24)) draw = ImageDraw.Draw(img) draw.rectangle((400,400,600,600), fill=(R,G,B)) root = Tkinter.Tk() photo = ImageTk.PhotoImage(img) label = Tkinter.Label(root, image=photo) label.pack() root.mainloop() Here is the (very)rough program #!/usr/local/bin/pythonw # Import needed modules import Tkinter, ImageTk import Image, ImageDraw import time, serial def measure(): ser.write("M\n") line = ser.readline() print line, def display(R,G,B): img = Image.new('RGB',(1000,1000),(24,24,24)) draw = ImageDraw.Draw(img) draw.rectangle((400,400,600,600), fill=(R,G,B)) root = Tkinter.Tk() photo = ImageTk.PhotoImage(img) label = Tkinter.Label(root, image=photo) label.pack() root.mainloop() def setup_comm(): ser = serial.Serial('/dev/tty.KeySerial1') ser.write("PR701\n") time.sleep(.2) ser.flushOutput() line = ser.readline() print line # Program Starts here setup_comm() display(0, 255, 255) measure() display(255, 0, 255) measure() display(255, 255, 0) measure() -- http://mail.python.org/mailman/listinfo/python-list