Tkinter problem (threads?)
Doug Hellmann
doughellmann at mindspring.com
Sat Apr 3 17:37:29 EST 1999
More information about the Python-list mailing list
Sat Apr 3 17:37:29 EST 1999
- Previous message (by thread): Rat sighting online
- Next message (by thread): Why are they? Re: Module Documentation Strings
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Robert, You might want to look into the after_idle method available from the Tkinter widget classes. It basically registers a function to be called during the next "idle" period of the event loop. The idle period is either after or before all normal events have been processed (I don't know which). I have successfully used this technique in several applications to do my processing "in the background" while the interface remains responsive. The trick is to remember that while your idle function is running, the interface *won't* update. Only after you return (or call update_idletasks will it update. The best thing to do is make your idle function perform only a small piece of your processing. For instance, in one program I had an idle function that polled several pipes using select to see if any of them had output. When it found output, it would read a small buffer, process it, and return. When it found no output it would return immediately. That way, the interface was very responsive, since my function didn't hang it up for very long. I kept my state information (list of pipes, portion of buffer not processed, etc.) as member variables of my application class. The idle function was a method of the class, so I could access everything I needed from the application instance. Oh, one other thing you need to know is that calling after_idle only registers the function to be called one time. You will need to have your function re-register itself if it has more processing to do. Let me know if you run into trouble, I'd be happy to help. Doug Robert Vollmert wrote: > > I'm experiencing a problem while writing a simple plotting program > using Tkinter: I've created a Plot class which, after being > initialized with a canvas instance, gets new values through an add > method. > > How can I make Tk enter the mainloop (in order to show the plot) and > still add new values afterwards? > > TIA, Robert > > -- > Robert Vollmert rvollmert at gmx.net
- Previous message (by thread): Rat sighting online
- Next message (by thread): Why are they? Re: Module Documentation Strings
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list