Tkinter app 'freezes' when I use after_idle

Andrew Markebo andrew.markebo at telelogic.se
Fri Oct 29 17:01:43 EDT 1999


Thanx, you showed me something I have missed.. it is probably what I
needed, the tkinter fileevent. but.. but.. now reading on.. Unix
only.. DARN! Any other hints.. 

        /Andy

/ Doug Hellmann <doughellmann at home.com> wrote:
| [...]
| Tk will not update the display while you are doing work in your idle
| handler unless you call update() or update_idletasks().  It sounds like
| you are doing that for some widgets, as you see some changes on the

Yep a couple of labels that I set..         

| display.  But if your idle handler blocks while reading data from the

I am trying not to block..using select to see if there are anything to
read,I don't know how much time is spent in my code around the select loop.. 

| network, it might take a while to come back.  Keep in mind that as long
| as the program is running your callback code, the display will not be
| updated.  

*HMM* Ok lets try to sort this out.. Of course the first call to the
 function is from a callback, when I press the 'go' button a call is
 made to 'checkfunc'. Last in checkfunc I call
 self.after_idle(checkfunc) this would stay away from the event??

| 
| You could use a file handler to let Tk watch the socket for you (instead
| of doing your own select).  You would then get a callback when there is
| data for you to read from the socket.  I've had success with this scheme

*bonk* I have heard about that, time to take a dig into my TCL/TK book again.. 

| watching the read end of a pipe.  As a little bit of data is available,
| I read it into a buffer.  When the pipe is empty (read 0 bytes in the
| event handler), I know I have all of the data and I start doing the real
| processing.  Of course, if you can process part of the data at a time
| that would be even more efficient.
| 
| Doug




More information about the Python-list mailing list