jomonantony has asked for the wisdom of the Perl Monks concerning the following question:
I am using the following code for a GUI in perl. In the case of buttons two clicks are needed for the action. how can i clear this??? Thanks in advance... My code is:
#!/usr/bin/perl -w use strict; use warnings; use Win32::GUI qw(CW_USEDEFAULT); use Win32::GUI::BitmapInline(); use Win32::Process; use Win32; my $ss; my $DOS = Win32::GUI::GetPerlWindow(); Win32::GUI::Hide($DOS); my $mw = Win32::GUI::Window->new( -title => "Test", -left => CW_USEDEFAULT, -size => [500,500], -color => 0x80FFFF, ); $mw->Animate( -show => !$mw->IsVisible(), -activate => 1, -animation => 'center', #-direction => $d, -time => 500, ); $mw->AddButton( -text => "Start", -left => $mw->Width() - 480, -top => $mw->Height() - 480, -size => [75,30], -onClick => \&fun2, ); $mw->AddButton( -text => "End", -left => $mw->Width() - 400, -top => $mw->Height() - 480, -size => [75,30], -onClick => \&fun12, ); $mw->AddButton( -text => "Process", -left => $mw->Width() - 320, -top => $mw->Height() - 480, -size => [75,30], -onClick => \&fun1, ); $mw->AddButton( -text => "Printer List", -left => $mw->Width() - 240, -top => $mw->Height() - 480, -size => [75,30], -onClick => \&funp, ); $mw->Show(); Win32::GUI::Dialog(); $mw->Hide(); undef $mw; exit(0); our ($pid,$user,$proc,$dn,$str); sub fun1() { $ss=""; for my $line (`tasklist /v /nh`) { chomp($line); if ( $line ne "" ) { # extract PID my $pid = substr($line, 26, 6); # remove leading spaces $pid =~ s/^ *([0-9]+)$/$1/g; # extract username my $user = substr($line, 88, 50); # remove trailing spaces $user =~ s/^(.*\S)\s+$/$1/g; # change spaces in username to underscores $user =~ s/\s/\_/g; # extract process my $proc = substr($line, 0, 24).substr($line, 152, 72); # change multiple spaces to single spaces $proc =~ s/\s\s\s*/ /g; # remove trailing space $proc =~ s/\s$//g; # remove trailing N/A $proc =~ s/ N\/A$//g; # print tab seperated fields print $pid, "->", $user, "->", $proc, "\n"; $ss=$ss."$pid->$user->$proc\r\n"; if($proc =~ /perl.exe C:\\Perl\\bin\\perl.exe/) { print "YEEEEEEEEEEEEEEEEEEEE"; `taskkill /PID $pid`; } } } $pid = 111; $mw->AddTextfield( -name => 'time', -text => $ss, #-prompt => [ "Test Text Field:", 80 ], -pos => [20,100], -size => [300,300], -align => 'left', -multiple => 1, -number => 0, -multiline => 1, -hscroll => 1, -vscroll => 1, -autohscroll => 1, -autovscroll => 1, ); #print "Current process' parent PID is " . getppid(); } sub fun2() { system("invoice_snail.pl"); } sub funp() { $str=""; my @pp=`cscript prnjobs.vbs -l`; foreach my $pp (@pp) { if($pp =~ /Document/) { $dn=$pp; $dn=~ s/Document //; $dn=~ s/.*[\/\\](.*)/$1/; $str=$str.$dn."\t"; } if($pp =~ /Job status/) { $str=$str.$pp."\r\n"; } } $mw->AddTextfield( -name => 'time', -text => $str, #-prompt => [ "Test Text Field:", 80 ], -pos => [20,100], -size => [300,300], -align => 'left', -multiple => 1, -number => 0, -multiline => 1, -hscroll => 1, -vscroll => 1, -autohscroll => 1, -autovscroll => 1, ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl GUI
by Anonymous Monk on May 25, 2010 at 07:36 UTC |