briannz556 has asked for the wisdom of the Perl Monks concerning the following question:

Illustrious Ones, I've a Loft Gui program written that searches for specific file extensions. The program works fine but I have a troublesome richedit line that won't display as I wish.
The code behind a button to begin a search is as follows: sub ::btnSearch_Click{defined(my $win = $Win32::GUI::Loft::window{"Sea +rch and Delete"} ) or return(1); # check path acceptable since user may have al +tered the default $path = $win-> tfSearchPrefix-> Text; if (!(-e "$path")) { $win-> reReport-> Text("Search path does n +ot exist ..."); return; } else { $win-> reReport-> Text("Searching for medi +a files ..."); }; # open link to text storage file for each exte +nsion checked sleep(4); foreach (@ext) { my $fh; # filehandle my $extension = getdcwd()."\\Extensions\\$_\ +.txt"; # holds matching file extensions open ($fh, ">$extension") or die "Cannot ope +n $_ for write :$!"; $handle{$_}= $fh; }; find({wanted => \&wanted, no_chdir=>1}, $path) +; # close link to storage file for each extensio +n foreach (@ext) { close $handle{$_}; }; $win-> reReport-> Text("Finished Searching"); } and the subroutine wanted is defined as follows: sub wanted {defined(my $win = $Win32::GUI::Loft::window{"Search and De +lete"} ) or return(1); if (!("$File::Find::dir"=~/}/)&&(/\.asf$|\.mp.{0,2}$|\.avi$|\.exe$ +|\.wav$|\.zip$|\.mov$|\.rm.?$ |\.wm.?$|\.qt$|\.mid.?$|\.ra.?$|\ +.swf$|\.pst$|\.ogg$|\.gho$/i)) { my ($type) = /\.(\w\w)\w?$/; print {$handle{lc $type}} "$_\n"; } }
I can only get "Searching for media files ..." to appear if I comment out find({wanted => \&wanted, no_chdir=>1}, $path); and by necessity $win-> reReport-> Text("Finished Searching");. The latter needs commenting or the initial comment gets wiped before I see it appear. The sleep line I've varied but to no avail. The line "Finished Searching" appears fine. Can anyone offer me a suggestion as to how I can get "Searching for media files ..." to appear so the user can understand that something is happening? Any help appreciated. Your obedient servant

Replies are listed 'Best First'.
Re: Loft Richedit issue - I think
by BrowserUk (Patriarch) on Aug 13, 2007 at 09:23 UTC

    Try calling Update() after you set the text. eg.

    } else { $win-> reReport-> Text("Searching for media files ..."); $win->reReport->Update; };

    You'll have to do the same thing after each update to the window because you are not allowing the code to return to the message loop. Ideally, you should hive long running (more 1/10th second) processing off into a separate thread, but that is probably overkill until you gain more experience with the GUI toolkit.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Wonderful. Just what I needed. Had searched everywhere and never found this option but it had been a month since I'd been using the GUI toolkit. I've searched again in Win32::GUI Docs and found the method you gave me. Appreciate the quick response.