http://www.perlmonks.org?node_id=1019452


in reply to Re^2: Win32 GUI freeze
in thread Win32 GUI freeze

When you post code, you need to put it inside <code></code> tags, which makes it much easier for others to read.

I've posted your code reformatted in a more easier to read format below. However, while reformatting your code, I noticed that it looks like there are some issues with curly brackets. There are some areas that are missing the closing curly brackets and then there are extra curly brackets at the end of your code.

use thread; use Parallel::ForkManager; use Data::Dumper; use Net::Telnet; use Win32::API; use Win32::GUI(); $main = Win32::GUI::Window->new( -name => 'Main', -width => 500, -height => 900, -text => 'Perl', -minsize => 500, 900, ); my $loadImage = new Win32::API ('user32', 'LoadImage', 'N','N','I','I' +,'I','I','N') or die 'cannot find LoadImage function'; my $waitCursor = $loadImage->Call(0, 32514, 2, 0, 0, 0x8040); my $font = Win32::GUI::Font->new( -name => "Comic Sans MS", -size => 8 +,); $main->AddLabel(-text => "Welcome ", -pos => 10, 10 , -size => 190, 12 +5 ,); $main->AddLabel(-text => "Enter Host Name / IP : ", -pos => 10, 33 , - +size => 190, 125 , ); my $t= $main->AddTextfield( -name => 'tfResults', -text => "hostname", + -pos => 125, 30 , -size => 100, 25 , ); my $my_but = $main->AddButton(-text => "Submit",-name => 'btQuery', -p +os => 235, 30 ,-size => 50, 25 ,); $main->Show(); Win32::GUI::Dialog(); sub btQuery_Click { $main-> DoEvents(); $txt1=$t->Text; if ($txt1) { my $txt1=$t->Text; if($txt1=~/a-zA-Z0-9+/) { #CHECKING WINDOWS OR UNIX HOST BY CALLING BELOW FUNCTION $oldCursor = Win32::GUI::SetCursor($waitCursor); #show hourglass ... print "\nConnecting to : $txt1"; &host1($txt1); if($hosttype=~/Unix/) { $t->ReadOnly(1); $my_but->Disable(); &unix_host; } elsif($hosttype=~/Windows/) { $t->ReadOnly(1); $my_but->Disable(); &win_host; } elsif($hosttype=~/unknowhost/) { $main->AddLabel(-text => "", -pos => 10, 200 , -size => 500, 5 +00 ,); $main->AddLabel( -text => "Unable to connect host. Please check the host name +/ip.", -pos => 10, 200 , -size => 500, 950, -font => $font, -foreground => 0, 0,250, ); print "\nUnknow host. Please check the host name/ip."; last; } # Connecting to Unix host sub unix_host { my $txt1=$t->Text; $main->AddLabel(-text => "", -pos => 0, 200 , -size => 500, 900 ,); $main->AddLabel(-text => "Please wait.....logining to host. ", -pos +=> 10, 200 , -size => 500, 500 ,); $telnet = new Net::Telnet ( Timeout=>1800, Errmode=>'die', input_log=>'input.log', output_log=>'output.log', Dump_Log=>'dump.log', Option_log=>'option.log' ); $telopt_ttype_ok = ''; $telnet->option_callback(\&opt_callback); $telnet->option_accept(Do=>Net::Telnet->TELOPT_TTYPE); $telnet->suboption_callback(\&subopt_callback); chomp $txt1; $telnet->open($txt1); my $oldCursor = Win32::GUI::SetCursor($waitCursor); #show hourglass ... $telnet->waitfor('/login: $/i'); $telnet->print('root'); $telnet->waitfor('/Password: $/i'); $telnet->print('dangerous'); $telnet->waitfor('/# $/i'); print "\nConnected to Unix host :$txt1 "; print FILE "\n@time1:Connected to Unix host: $txt1"; $main->AddLabel(-text => "Connected to Unix host. ", -pos => 10, 500 + , -size => 500, 500 ,); #print "\nSetting symcli and adios path on host."; #my $PATH = '/usr/symcli/bin:/usr/adios'; #$telnet->print("PATH=$PATH"); #PATH=$PATH:/data/myscripts #$telnet->print("PATH=$PATH:/usr/symcli/bin:/usr/adios"); #$telnet->print("export PATH"); #$telnet->waitfor('/# $/i'); Win32::GUI::SetCursor($oldCursor); #show previous arrow cursor again $check1=$main->AddButton(-name => "Unix_Check",-text => "Check versi +on",-pos => 55, 70 ,); $main->AddLabel(-text => " Enter custom cmd:",-pos => 10, 100 ,-size + => 250, 125 ,); $t1= $main->AddTextfield(-name => 'tfResults2',-text => "",-pos => 1 +30, 100 ,-size => 100, 25 ,); $submit=$main->AddButton(-text => "Submit",-name => 'Unix_submit',-p +os => 250, 100 ,-size => 50, 25 ,); sub Unix_Check_Click { } sub Unix_submit_Click { } } } } }

Replies are listed 'Best First'.
Re^4: Win32 GUI freeze
by ckant8 (Acolyte) on Feb 19, 2013 at 06:35 UTC
    Sorry for the trouble.. i have just added a snap of my code.
Re^4: Win32 GUI freeze
by bulk88 (Priest) on Feb 20, 2013 at 07:11 UTC