Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Handling long running processes in tk

Posted by rgm1960 (rgm1960), 19 September 2005
I am creating a gui for a scientific app that has a couple of long running processes. For instance when I push a button "Run", the callback proc of "Run" calls another function (loaded during initialization by doing "load my.dll RunCmd") This function takes about 60sec or so to return and during this whole time the button "Run" stays pushed (active). How do I get the button to be in a normal state immediately after its callback is invoked and instead have my cursor turn to, say an hour glass until the function returns to the tcl script? Any insights will be appreciated. Thanks.

Posted by admin (Graham Ellis), 20 September 2005
You're looking for the update idletasks command ... and we've an example of it in use in a live application at

In normal running, Tk only updates the display when it has nothing else to do, for the very good reason that you don't want to see you GUI growing slowly as you first build it up, nor see a whole long series of incremental changes flash by you when you take some action that results in (for example) a window being resized.

In cases where you make a selection on the GUI that's going to tie the process up for a while, though, you want to be able to change this behaviour and give an immediate feedback to the user that, yes, his button press was noted and is being acted on.  So add an update idletasks command near the start of the long-to-run process, just after you have made the GUI command calls to alter the display; this forces all pending GUI changes to be actioned

You may want to go further; if you want to give some sort of progress bar for your long rinning process ... let's say it's of the form of a loop that runs 3 times (like my ping example), you could updatethe display every time through the loop.   But be very careful that you don't put the update within a tight loop - it would be very easy to slow down the process as a whole.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho