Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Win32::GUI event issues

by orbital (Scribe)
on Mar 30, 2001 at 01:07 UTC ( [id://68201]=perlquestion: print w/replies, xml ) Need Help??

orbital has asked for the wisdom of the Perl Monks concerning the following question:

My company just hired a Jr. Technician to help out with the NT administration and the idiot doesn't even know what a dos prompt is. A direct quote from Jr. Tech "All my experince is dealing with Graphical Interfaces, I don't have time to learn dos". I said "What about automation and diagnostics? A command line can offer you much greater power." He had no comment to this remark.

Besides the point that the management are a bunch of monkeys for hiring someone with so little technical competence, I am no stuck babysitting. Having one of the key virtues of perl down "Laziness" I decided I would be better off porting my major tools over to a GUI, this way I didn't have to hold my breathe while he tried to learn dos. I have had quite a bit of success at using Win32::GUI for dealing with my problem. However today I hit a brick wall with one of the scripts.

I have one Window object that accepts all the user input and flags with a submit button on the window. When the submit button is hit I have an event that displays the result in a different Window object that then becomes visible. This works great!

sub submit_Click { print $count++; %Config = (); # Several lines of logic to determine and stores # users values and settings into %Config display_results(/%Config); #builds my results window $Display->Show(); #my display window }

My problem is when I terminate the result window after the first time everything seems to break.

sub Display_Terminate { $Display->Hide(); $Window->Enable(); #Grasping at straws return 0; }
I try to do another query using my submit button, it seems that my submit_click event is ignored the second time around, however the result window still pops up but this time with different results, it doesn't pull any of my definitions or flags, it justs uses the code defaults. Notice my submit_click event I added this line for debugging
print $count++;

The very first time I click the submit button I get what I expect, a 0 on the command line. Once I have gone through the cycle once it fails to display any more on the command line, ignoring my event altogether. What also baffles me is the fact that the result window displays at all considering that it doesn't seem to get into my desired event. This is the only place in the entire script that the Result window is made visible.

Any ideas on what is causing my event to not be reconized properly?

Replies are listed 'Best First'.
Re: Win32::GUI event issues
by orbital (Scribe) on Mar 30, 2001 at 03:52 UTC
    I found my problem and it wasn't with how my events were setup it was how I was handling my results. In my code examples above in the submit_Click event: display_results(\%Config); My problem was since this was orginally a command line script I was putting all the code in the display_results sub, I modified the code in there to redirect the output to a variable using select. I know I read an article about the evils of this command in Win32 but I can't find the node right now. I believe the credit goes to Tilly.

    When I took this line out and cleaned up my code to be both Command line and GUI aware, everything was working great!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://68201]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-13 19:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found