in reply to Newbie with a TK question

the main window freezes until the all the directories have been parsed.

Well think about it, the program's execution pointer is busy devoting full time to parsing the directories, so the window-gui seems to lock up. This is one of the most common problems faced when doing GUI's, so don't feel bad.

There are many solutions. The simplest solution is to liberally sprinkle "$mw->update" throughout your directory parsing sub, like:

# get info from dictionary files while(($folder, $drive) = each %search_locations) { #get list of files in directory $mw->update; $var = "Looking in - $drive/DICT/SOURCE\n"; chdir "$drive/variable/DICT/SOURCE"; $mw->update; @file_list = glob ("*.dsf"); $mw->update; $var = “Num of files: $#file_list”; }
That may be excessive, but everytime you call $mw->update, your gui will get some processor time.

The other options involve forking off your dir-processing and using Tk::fillevent to read the results, in a non-blocking manner. You can also do the same thing with threads.

So it depends how how much time passes in the lines between each $mw->update. If they are on your local machine, it's probably fast, but if it's over a network link, it may be slow. So then you may have to use fileevent, forks and/or threads. Generally in a GUI, you never use "while(1)" or "sleep", because it blocks the gui.

Your problem is usually called "blocking the gui", and you can google for "Tk non blocking" to see the myriad of situations and solutions, people have used talked about, regarding blocking the gui.


I'm not really a human, but I play one on earth. flash japh