Hey Kevin

You should use the Win32::GUI::Dialog() call instead of calling sleep
and DoEvents explicitly.. You do a "sleep" for each line in the file,
so it's no surprise it takes forever to read...

This will also keep your program running after it exits the last loop.

To read the file you can use a timer:

 $main->AddTimer('ReadFile',1000);

 sub ReadFile_Timer{
     open INFILE, "<$infile" or die "open infile error: $! File:
$infile";
     my $output;
     foreach my $line (<INFILE>) {
         chop $line;
         $output.="$line\r\n";
     }
     $main->Textfield->Change(-text => $output);
 }



- Nikolaj
 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Kevin L. Gross
> Sent: 31. maj 2006 02:32
> To: perl-win32-gui-users@lists.sourceforge.net
> Cc: darrik
> Subject: Re: [perl-win32-gui-users] Need an example, please.
> 
> 
> Thanks for the suggestion. I tried it and it works...sort of.
> 
> 
> First off, it is painfully slow. Takes a couple of minutes 
> for a small file (2K) to display, one line at a time. This 
> can't be normal for Perl on Windows can it? 
> 
> Second, no scroll box, even tho the -multiline and 
> -autovscroll parameters are set to 1.
> 
> Third, the GUI app disappears completely after the last line 
> is printed. How do you keep the window (and/or DOS command 
> window) up and displayed?
> 
> Isn't there a better way to flow text into a scroll-bar field 
> or window or dialog or something?
> 
> -Kevin
> 
> 
>   use strict;
>   use Win32::GUI;
> 
>   my $main = Win32::GUI::Window->new(
>     -name    => "Main",
>     -title   => "Win32-GUI: Doevents-Demo",
>     -left    => 100,
>     -top     => 100,
>     -width   => 600,
>     -height  => 800,
>   );
> 
>   sub Main_Terminate() {
>     print "Main window terminated\n";
>     return -1;
>   }
> 
>   my $textfield = $main->AddTextfield(
>     -name   => "Textfield",
>     -text   => "have fun and more",
>     -left   => 75,
>     -top    => 150,
>     -width  => 200,
>     -height => 600,
>     -readonly => 1,
>     -multiline   => 1,
>     -autovscroll => 1
>   );
> 
>   $main->Show();
> 
>   my $output;  # possibly declare this globally further up...
>   my $infile="/Documents and 
> Settings/Kevin/Desktop/Stuff/Perl/samplegui2.pl";
>   $output.="Processing infile $infile...";
>   $textfield->Text($output);
>   open INFILE, "<$infile" or die "open infile error: $! File: 
> $infile";
>   foreach my $line (<INFILE>) {
>     chop $line;
>     $output.="$line\r\n";
>     #$textfield->Text($output);
>     #print "$line\n";
>    
>    Win32::GUI::DoEvents() >= 0 or die "Window was closed 
> during processing";
>    sleep 1;   #body of the loop...
>   }
>    
>   $output.="completed";
>   $textfield->Text($output);
>   Win32::GUI::DoEvents();
>   sleep 1;    #program continues...
> 
> 
> 
> -------------------------------------------------------
> All the advantages of Linux Managed Hosting--Without the Cost 
> and Risk!
> Fully trained technicians. The highest number of Red Hat 
> certifications in the hosting industry. Fanatical Support. 
> Click to learn more
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&;
> dat=121642
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
> 

Reply via email to