From: Jason P. <jp...@un...> - 2007-07-26 13:45:05
|
This is not a GUI issue per se, as it is the fact that your routine runs synchronous, in the main thread of the application. To remove this lag = (and the delayed drawing of the window) you will need to do some looking = through the mail archives and find how to write this into a separate thread. -----Original Message----- From: per...@li... [mailto:per...@li...] On Behalf Of Marc N=FCrnberger Sent: Thursday, July 26, 2007 7:21 AM To: per...@li... Subject: [perl-win32-gui-users] Why is my GUI hanging? Hi everyone, I tried to create a little GUI for a program which I wrote a while ago. It's only a little link filter. I have to give him an URL, he parses the website for given regular expressions and gives back a HTML file with all the links in it. Now the problem is that if i enter the URL and click on the Button to proceed, the program hangs for about 30 seconds before it goes on. Everything works fine. Only this "lag" is very disappointing. I can't find my mistake... If I do the same on the console, everything works instantly without = hanging. I would be glad if someone could help me out. :) Here's the code: use LWP::UserAgent; use HTTP::Cookies::Mozilla; use Win32::GUI(); # Use of the Firefox Cookie file # For German Systems: Change the Docume~1 to Dokume~1 # I'm working on a better solution for this $kekse =3D HTTP::Cookies::Mozilla->new( 'file' =3D> glob("C:/Docume~1/$ENV{'USERNAME'}/Anwendungsdaten/Mozilla/Firefox/Profil= es/ *.default/cookies.txt")); # Creation of the LWP Useragent with the Firefox Cookie file $ua =3D LWP::UserAgent->new; $ua->agent('Mozilla/5.0'); $ua->cookie_jar($kekse); # Creation of the GUI $main =3D Win32::GUI::Window->new( -name =3D> 'Main', -width =3D> $width =3D 295, -height =3D> $height =3D 161, -maximizebox =3D> 0, -resizable =3D> 0, -text =3D> 'Link Filter', ); $lblURL =3D $main->AddLabel( -name =3D> 'lblURL', -width =3D> 100, -height =3D> 17, -align =3D> 'left', -left =3D> 4, -top =3D> 4, -text =3D> 'Bitte URL eingeben:', ); $tfURL =3D $main->AddTextfield( -name =3D> 'tfURL', -width =3D> 281, -height =3D> 77, -align =3D> 'left', -left =3D> 4, -top =3D> 20, -multiline =3D> 1, ); $btGet =3D $main->AddButton( -name =3D> 'btGet', -width =3D> 279, -height =3D> 33, -left =3D> 5, -top =3D> 100, -text =3D> 'Get Them!', ); $desk =3D Win32::GUI::GetDesktopWindow(); $deskwidth =3D Win32::GUI::Width($desk); $deskheight =3D Win32::GUI::Height($desk); $deskx =3D ($deskwidth - $width) / 2; $desky =3D ($deskheight - $height) / 2; $main->Move($deskx, $desky); $main->Show(); Win32::GUI::Dialog(); sub Main_Terminate { return -1; } sub btGet_Click { # Copy the entered URL into a usable variable $url =3D $tfURL->Text; return -1; } # Get the content of the Website and save it into a temporary HTML file $ua->get($url, ':content_file' =3D> 'temp.html'); open(EINGABE, "temp.html") || die("Fehler: Datei temp.html konnte nicht gefunden werden."); open(AUSGABE, ">links.html") || die("Fehler: konnte Datei rs.html nicht erstellen."); # Filter the links from the temporary file and write them into a new HTML file while($zeile =3D <EINGABE>) { if ($zeile =3D~ m/ENTER YOUR REGEXP HERE/) { $zeile =3D~ s/ENTER YOUR REGEXP HERE/AND HERE/; print AUSGABE "<a href=3D\"" . $zeile . "\">" . $zeile . "</a>" . "<br>"; } } close(EINGABE); close(AUSGABE); # Delete temporary file unlink "temp.html"; # Open the file which holds the filtered links `links.html`; -------------------------------------------------------------------------= This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/ --=20 No virus found in this incoming message. Checked by AVG Free Edition.=20 Version: 7.5.476 / Virus Database: 269.10.20/919 - Release Date: = 7/26/2007 9:56 AM |