Hi,
I'm trying to write a prog that eventually uses checkboxes
and a button to run small perl scripts and display the results.
I appreciate any help or pointers, I'm using ActiveState5.8
(the latest).
Whenever a checkbox is selected and the button is pressed, I'd
like the results to flow into a textfield in the window. But I
am new to win32::gui and can't seem to find a good example.
Below I am simply trying to display each line of a known text
file. The code below only shows the latest $textfield->Text()
call because the $main->Show() only shows the most recent text.
How can I keep the text in the windows textfield with a scrollbar?
Is there a better way?
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 => 400,
);
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 => 80,
-readonly => 1,
-multiline => 1,
-autovscroll => 1
);
$main->Show();
my $infile="/Documents and Settings/Kevin/Desktop/Stuff/Perl/samplegui2.pl";
$textfield->Text("Processing infile...");
open INFILE, "<$infile" or die "open infile error: $! File: $infile";
my $linenr = 0;
foreach my $line (<INFILE>) {
chop $line;
$textfield->Text("$line\r\n");
print "$line\n";
Win32::GUI::DoEvents() >= 0 or die "Window was closed during processing";
sleep 1; #body of the loop...
}
$textfield->Text("completed");
Win32::GUI::DoEvents();
sleep 1; #program continues...
Thanks,
-Kevin