RE: [perl-win32-gui-users] Win32::GUI help
I think I did kind of the same thing you are looking at. What I had to do was create a child process to handle all my requests. Take a look at Win32::ProcFarm to create and talk with your children processes while having your parent process deal with the interface. Give that a shot =-) I will try to find some of my code and send it on. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of #SHUCHI MITTAL# Sent: Wednesday, January 07, 2004 7:30 AM To: perl-win32-gui-users@lists.sourceforge.net Subject: [perl-win32-gui-users] Win32::GUI help Hi once again everyone I just started working with Win32::GUI yesterday and was wondering if anyone could tell me how I can do the following: 1/ Make a basic GUI with certain buttons-- I have successfully managed to make this!!:) 2/ Every button click should invoke another perl script -- I think I can do this by including the system command in the button click method. If anyone knows any other sophisticated method then pelase tell me 3/ I need to display the output while execution of each of the scripts, that runs on a button click, on some sort of box/window. This box or window can appear on the original window or pop up a new one which would close once execution finishes. that is : I have a basic window with buttons. on click of button I should see a text box or a pop up window which shows me the result of the script execution. If its a pop up window it should close when script finishes execution and if its a text box then it can just stay as it is once the execution finishes. I I have NO idea how to do this so any sort of help would be great. I tried reading some tutorials on Win32::GUI but Im still lost. Any advice/script snippets to start me off would be much appreciated. Thanx in advance Cheers Shuchi --- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78alloc_id371op=click ___ Perl-Win32-GUI-Users mailing list Perl-Win32-GUI-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
RE: [perl-win32-gui-users] Win32::GUI help
Hi, 2/ Every button click should invoke another perl script -- I think I can do this by including the system command in the button click method. If anyone knows any other sophisticated method then pelase tell me You can run your perl scripts using perl's do keyword: do 'myscript.pl'; However this may lead to problems, like if myscript.pl dies, your whole script will die. The very best way to handle it is to fork, as in my example below. The added advantage of forking is the script you started will run independently of your window script, so you dont have to wait for it to exit if you want to start another script running or do something else with the GUI. Here's how to do it: # Signal handler for when child threads die. # Probably not required on Win32. Put this near the top # of your script. sub REAPER {wait; $SIG{CHLD} = \REAPER;} $SIG{CHLD} = \REAPER; # # Your GUI code goes here. # # Example handler for a button called buttonA. # change 'myscript.pl' to whatever script you want to run. sub ::buttonA_Click { my $pid = fork; if(!defined($pid)) { die Fork failed }; if($pid == 0) { # This is the child thread do 'myscript.pl'; exit; # This quits our child. } } 3/ I need to display the output while execution of each of the scripts, that runs on a button click, on some sort of box/window. This box or window can appear on the original window or pop up a new one which would close once execution finishes. that is : I have a basic window with buttons. on click of button I should see a text box or a pop up window which shows me the result of the script execution. If its a pop up window it should close when script finishes execution and if its a text box then it can just stay as it is once the execution finishes. I I have NO idea how to do this so any sort of help would be great. I tried reading some tutorials on Win32::GUI but Im still lost. Any advice/script snippets to start me off would be much appreciated. The hardest part is capturing the output of your auxiliary scripts as they run. One way to do this is make a function in your GUI script that appends a line to a textfield somewhere. Let's say this function is called logline() and takes an argument of $text. You can call the function from your external script (which we called 'myscript.pl' above) by using MAIN::logline(some text). This means replacing all those print statements with MAIN::logline() instead. Steve
RE: [perl-win32-gui-users] Win32::GUI help
Here ya go: All the use's were done to allow for perl2exe to compile it into an application. The code is really really sloppy. =( Also I used guiloft to create the win32::Gui stuff... Way easier.. I would highly recommend it! =-) ---CODE--- #!e:\perl\bin\perl #this is the parent script use Win32::GUI; use Win32; use Win32::GUI::Loft; use Win32::GUI::Resizer; use Win32::GUI::ToolbarWindow; use Win32::GUI::BorderlessWindow; use Win32::GUI::Loft::Cluster; use Win32::GUI::Loft::ControlProperty; use Win32::GUI::Loft::ControlProperty::Readonly; use Win32::GUI::Loft::ControlInspector; use Win32::GUI::Loft::Control; use Win32::GUI::Loft::Control::ForegroundBackground; use Win32::GUI::Loft::Control::Intangible; use Win32::GUI::Loft::Control::Window; use Win32::GUI::Loft::Control::Button; use Win32::GUI::Loft::Control::Textfield; use Win32::GUI::Loft::Control::RichEdit; use Win32::GUI::Loft::Control::Label; use Win32::GUI::Loft::Control::Checkbox; use Win32::GUI::Loft::Control::Radiobutton; use Win32::GUI::Loft::Control::Listbox; use Win32::GUI::Loft::Control::Combobox; use Win32::GUI::Loft::Control::TreeView; use Win32::GUI::Loft::Control::ListView; use Win32::GUI::Loft::Control::Groupbox; use Win32::GUI::Loft::Control::Toolbar; use Win32::GUI::Loft::Control::StatusBar; use Win32::GUI::Loft::Control::ProgressBar; use Win32::GUI::Loft::Control::TabStrip; use Win32::GUI::Loft::Control::Splitter; use Win32::GUI::Loft::Control::ImageList; use Win32::GUI::Loft::Control::Timer; use Win32::GUI::Loft::Control::Custom; use Win32::GUI::Loft::Control::Graphic; use Win32::GUI::Resizer; use Data::Dumper; use IO::Socket; use Cwd; use Data::Dumper; use Win32::Process; use Win32::ProcFarm::Port; use Win32::ProcFarm::TickCount; use Win32::ProcFarm::Parent; use Win32::ProcFarm::Port; #this hides the dos window =-) yeah! my ($DOS) = Win32::GUI::GetPerlWindow(); Win32::GUI::Hide($DOS); my $port_obj = Win32::ProcFarm::Port-new(9000, 1); my $interface = Win32::ProcFarm::Parent-new_async($port_obj, perl_script.pl, Win32::GetCwd); $interface-connect; sub main { # this code from here to the other here (lol) is all I need to create the window. Ergo why GUILOFT ROCKS! my $fileWindow = Hotfix.gld; my $objDesign = Win32::GUI::Loft::Design-newLoad($fileWindow) or die(Could not open window file ($fileWindow)); #Create a menu and assign it to the design object before #building the window. $objDesign-mnuMenu( Win32::GUI::MakeMenu( File=mnuFile, Save= mnuFileSave, Save All= mnuFileSaveAll, Exit= mnuFileExit, Help= mnuHelp, About= mnuHelpAbout ) ); my $win = $objDesign-buildWindow() or die(Could not build window ($fileWindow)); $win-Show(); # the other HERE! =-) } sub ::btnOpen_Click { $jobServerToProcess = localhost; $interface-execute('check_server', $jobServerToProcess); } ---END CODE--- ---CODE--- #!e:\perl\bin\perl #this is the child process use Data::Dumper; use IO::Socket; use Win32::GUI; my ($DOS) = Win32::GUI::GetPerlWindow(); Win32::GUI::Hide($DOS); sub init { my($port_num, $unique) = @ARGV[0,1]; $socket = new IO::Socket::INET (localhost:$port_num) or die Child unable to open socket.\n; print $socket pack(V, $unique); } sub main_loop { my $len, $cmd; my $temp = read($socket, $len, 4); $temp or exit; $temp == 4 or die Unable to completely read command length.\n; $len = unpack(V, $len); (read($socket, $cmd, $len) == $len) or die Unable to completely read command.\n; my($command, $ptr2params); eval($cmd); my(@retval) = $command(@{$ptr2params}); my $retstr = Data::Dumper-Dump([EMAIL PROTECTED], [ptr2retval]); print $socket (pack(V, length($retstr)).$retstr); } init; while(1) { main_loop; } sub check_server { my($server) = shift; # do your stuff here! =-) }
RE: [perl-win32-gui-users] Win32::GUI help
I build it with perl2exe as well but that will require a small mod to the parent.pm in procfarm. The change has been submitted to the creator of procfarm but he has not released it. I tested it on XP and NT4 and 2K so as far as I can tell once it is compiled as long as you are calling the lowest common denominator for the OS's it should work =-) Open parent.pm and look for the following code: sub _new_async { my $self = shift; my $process; my $unique = $Win32::ProcFarm::Parent::unique++; my $port_num = $self-{port_obj}-get_port_num; (my $perl_exe = $^X) =~ s/\\[^\\]+$/\\Perl.exe/; Win32::Process::Create($process, $perl_exe, perl $self-{script} $port_num $unique, 0, 0, $self-{curdir}) or die Unable to start child process.\n; $Win32::ProcFarm::Parent::processes-{$unique} = $process; $self-{state} = 'init'; return $self; } Replace it with this code: sub _new_async { my $self = shift; my $process; my $unique = $Win32::ProcFarm::Parent::unique++; my $port_num = $self-{port_obj}-get_port_num; if($self-{script}=~ /\.exe/ig){ Win32::Process::Create($process, .\/$self-{script}, $self-{script} $port_num $unique, 0, 0, $self-{curdir}) or die Unable to start child process. .\/$self-{script} $port_num $unique\n; } else { (my $perl_exe = $^X) =~ s/\\[^\\]+$/\\Perl.exe/; Win32::Process::Create($process, $perl_exe, perl $self-{script} $port_num $unique, 0, 0, $self-{curdir}) or die Unable to start child process. perl $self-{script} $port_num $unique\n; } $Win32::ProcFarm::Parent::processes-{$unique} = $process; $self-{state} = 'init'; return $self; } -Original Message- From: Jeremy White [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 9:16 AM To: [EMAIL PROTECTED] Cc: perl-win32-gui-users@lists.sourceforge.net Subject: RE: [perl-win32-gui-users] Win32::GUI help Looks good - I'll have to have a play. Have you had any issues rolling out your exe across different versions of windows? Do you build the child with perl2exe before shipping it out? Thanks, jez. From: Farrington, Ryan [EMAIL PROTECTED] CC: 'perl-win32-gui-users@lists.sourceforge.net' perl-win32-gui-users@lists.sourceforge.net Subject: RE: [perl-win32-gui-users] Win32::GUI help Date: Wed, 7 Jan 2004 08:17:12 -0600 Here ya go: All the use's were done to allow for perl2exe to compile it into an application. The code is really really sloppy. =( Also I used guiloft to create the win32::Gui stuff... Way easier.. I would highly recommend it! =-) ---CODE--- #!e:\perl\bin\perl #this is the parent script use Win32::GUI; use Win32; use Win32::GUI::Loft; use Win32::GUI::Resizer; use Win32::GUI::ToolbarWindow; use Win32::GUI::BorderlessWindow; use Win32::GUI::Loft::Cluster; use Win32::GUI::Loft::ControlProperty; use Win32::GUI::Loft::ControlProperty::Readonly; use Win32::GUI::Loft::ControlInspector; use Win32::GUI::Loft::Control; use Win32::GUI::Loft::Control::ForegroundBackground; use Win32::GUI::Loft::Control::Intangible; use Win32::GUI::Loft::Control::Window; use Win32::GUI::Loft::Control::Button; use Win32::GUI::Loft::Control::Textfield; use Win32::GUI::Loft::Control::RichEdit; use Win32::GUI::Loft::Control::Label; use Win32::GUI::Loft::Control::Checkbox; use Win32::GUI::Loft::Control::Radiobutton; use Win32::GUI::Loft::Control::Listbox; use Win32::GUI::Loft::Control::Combobox; use Win32::GUI::Loft::Control::TreeView; use Win32::GUI::Loft::Control::ListView; use Win32::GUI::Loft::Control::Groupbox; use Win32::GUI::Loft::Control::Toolbar; use Win32::GUI::Loft::Control::StatusBar; use Win32::GUI::Loft::Control::ProgressBar; use Win32::GUI::Loft::Control::TabStrip; use Win32::GUI::Loft::Control::Splitter; use Win32::GUI::Loft::Control::ImageList; use Win32::GUI::Loft::Control::Timer; use Win32::GUI::Loft::Control::Custom; use Win32::GUI::Loft::Control::Graphic; use Win32::GUI::Resizer; use Data::Dumper; use IO::Socket; use Cwd; use Data::Dumper; use Win32::Process; use Win32::ProcFarm::Port; use Win32::ProcFarm::TickCount; use Win32::ProcFarm::Parent; use Win32::ProcFarm::Port; #this hides the dos window =-) yeah! my ($DOS) = Win32::GUI::GetPerlWindow(); Win32::GUI::Hide($DOS); my $port_obj = Win32::ProcFarm::Port-new(9000, 1); my $interface = Win32::ProcFarm::Parent-new_async($port_obj, perl_script.pl, Win32::GetCwd); $interface-connect; sub main { # this code from here to the other here (lol) is all I need to create the window. Ergo why GUILOFT ROCKS! my $fileWindow = Hotfix.gld; my $objDesign = Win32::GUI::Loft::Design-newLoad($fileWindow) or die(Could not open window file ($fileWindow)); #Create a menu and assign it to the design object before #building the window. $objDesign-mnuMenu( Win32::GUI::MakeMenu( File=mnuFile, Save= mnuFileSave, Save All= mnuFileSaveAll, Exit= mnuFileExit
Re: [perl-win32-gui-users] Win32::GUI help-URGENT
Hi, I wouldn't use the Activestate Repository for win::gui - there are later versions available on the sourceforge site - you will have to manually install the module: http://sourceforge.net/projects/perl-win32-gui/ http://sourceforge.net/project/showfiles.php?group_id=16572package_id=12884 for perl 5.6 http://sourceforge.net/project/showfiles.php?group_id=16572package_id=104184 for perl 5.8 If you want to use a repository, have a look at http://perso.club-internet.fr/rocherl/Win32GUI.html it also contains the latest versions. Cheers, jez. - Original Message - From: #SHUCHI MITTAL# [EMAIL PROTECTED] To: perl-win32-gui-users@lists.sourceforge.net Sent: Tuesday, January 06, 2004 1:01 PM Subject: [perl-win32-gui-users] Win32::GUI help-URGENT Hello there I am computer engg student in Singapore and am currently developing a perl application for which I need to develop a small and simple GUI. For this I came across this Win32::GUI module and feel its very easy to use. However I'm having trouble with it and was hoping someone could help me since posts in forums etc havent been much help. I thought mailing here directly would be the best thing to do. Firstly i downloaded the package but when i say ppm install Win32-GUI i get an error as follows: Error: No valid repositories; Error 500 Can't connect to ppm.Activestate.com:80 (connect: Unknown error) at D:/Perl/site/lib/PPM/Repository.pm line 84 Error: 500 Can't connect to ppm-ia.Activestate.com:80 (connect: Unknown error) at D:/Perl/site/lib/PPM/Repository.pm line 84 I feel either there is something wrong with my pre-instaled modules or im doing something wrong, but have no idea what it is. Also if i try to run a simple script to make a window with one button or any other script that uses this module I get the following error: Can't locate loadable object for module Win32::GUI in @INC (@INC contains D:/Perl/lib D:/Perl/site/lib .) at GUI.pl line 1 Compilation failed in require at GUI.pl line 1 BEGIN failed--compilation aborted at GUI.pl line 1 Once again I think i'm not sure why this error is coming. I did copy the GUI.pm file in all the directories specified. Please tell me what else I should do. I am in a hurry and need to start developing soon which wont take time once this problem is solved. I am hoping someone would reply to be as soon as possible. Any suggestions/help/advise to put me onto track would be much appreciated! Thank you for your time. Hoping to hear from you soon Regards Shuchi --- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78alloc_id371op=ick ___ Perl-Win32-GUI-Users mailing list Perl-Win32-GUI-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
RE: [perl-win32-gui-users] Win32::GUI help-URGENT
Instead of copying, install it with PPM. Download the ZIP from Sourceforge for your build of Perl. I've run into the same thing when just trying to copy the appropriate files to their locations. If you use the one from Active state, it is only build .558. Sourceforge is .607 I believe. It looks like you are behind a Proxy. Did you read the Perl distribution docs on how to set up PPM (your environment) for a proxy? -Original Message- From: #SHUCHI MITTAL# [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 06, 2004 6:53 AM To: perl-win32-gui-users@lists.sourceforge.net Subject: [perl-win32-gui-users] Win32::GUI help-URGENT Hello there I am computer engg student in Singapore and am currently developing a perl application for which I need to develop a small and simple GUI. For this I came across this Win32::GUI module and feel its very easy to use. However I'm having trouble with it and was hoping someone could help me since posts in forums etc havent been much help. I thought mailing here directly would be the best thing to do. Firstly i downloaded the package but when i say ppm install Win32-GUI i get an error as follows: Error: No valid repositories; Error 500 Can't connect to ppm.Activestate.com:80 (connect: Unknown error) at D:/Perl/site/lib/PPM/Repository.pm line 84 Error: 500 Can't connect to ppm-ia.Activestate.com:80 (connect: Unknown error) at D:/Perl/site/lib/PPM/Repository.pm line 84 I feel either there is something wrong with my pre-instaled modules or im doing something wrong, but have no idea what it is. Also if i try to run a simple script to make a window with one button or any other script that uses this module I get the following error: Can't locate loadable object for module Win32::GUI in @INC (@INC contains D:/Perl/lib D:/Perl/site/lib .) at GUI.pl line 1 Compilation failed in require at GUI.pl line 1 BEGIN failed--compilation aborted at GUI.pl line 1 Once again I think i'm not sure why this error is coming. I did copy the GUI.pm file in all the directories specified. Please tell me what else I should do. I am in a hurry and need to start developing soon which wont take time once this problem is solved. I am hoping someone would reply to be as soon as possible. Any suggestions/help/advise to put me onto track would be much appreciated! Thank you for your time. Hoping to hear from you soon Regards Shuchi --- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78alloc_id371op=ick ___ Perl-Win32-GUI-Users mailing list Perl-Win32-GUI-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users