469,295 Members | 1,953 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,295 developers. It's quick & easy.

Perl XMLBuilder

Is anyone familiar with Win32::GUI::XMLBuilder? I think this is great for building GUI windows. I'm just learning how to use it and i'm having some problems. i have created my GUI, with my required buttons. now i want to make these buttons active using onClick. So when the button is click, i want to call and execute a separate perl script. Is there a way to do this? I can't even figure out how to close the GUI window when my 'Exit' button is selected. I've been searching the net and looking through books (obviously the wrong books) and can't find it.

Here is a snippet of my code showing the development of the GUI window, label and a couple of buttons in the window:

[HTML]use Win32::GUI::XMLBuilder;
my $gui = Win32::GUI::XMLBuilder->new(*DATA);
Win32::GUI::Dialog;
__END__


<GUI>
<Window name ='W' height='450' width='550' title='Title' left='340' top='220'>
<Font name='Bold_Title'
size='18'
face='Arial'
bold='1'
italic='0'
/>
<Font name='Bold'
size='9'
face='Arial'
bold='1'
italic='0'
/>

<Label name = 'Label'
text='Select Test Case for Execution:'
top='20'
height='$self->{W}->ScaleHeight/2'
align='center'
font='$self->{Bold_Title}'
/>


<Button name = 'Test Case'
text='Execute This Test Case'
top='100'
height='30'
left='50'
width='200'
onClick='sub{Here is where I want to call a perl script to run!!!}'
/>

<Button name = 'Exit'
text='Exit'
top='360'
height='30'
left='240'
width='70'
onClick='sub{Here is where I want to close the GUI window!!!}'
/>

</Window>
</GUI>[/HTML]
Nov 19 '07 #1
4 1503
Never mind...i figure it out!!!
Nov 19 '07 #2
eWish
971 Expert 512MB
If you would please share your solution, so that others can learn from your experience.

--Kevin
Nov 19 '07 #3
Sure, no problem. I wouldn't want anyone else to spend two days trying to figure this out like i did!

Create a subroutine to do what you want the button to execute and then use the 'onClick' to call the subroutine.

In order to run another perl script by clicking a button, it was as simple as using the 'do' in a subroutine. In order to close the main window by clicking the exit button, create a terminate subroutine. Here's a snippet:

[HTML]use Win32::GUI::XMLBuilder;
my $gui = Win32::GUI::XMLBuilder->new(*DATA);

Win32::GUI::Dialog;


sub Test_Case {
do "C:/code.pl";
}

sub Terminate{
return -1;
}

__END__

<Button name = 'Button'
text='Execute This Test Case'
top='300'
height='30'
left='300'
width='200'
onClick= 'Test_Case'
/>

<Button name = 'Exit'
text='Exit'
top='360'
height='30'
left='240'
width='70'
onClick='Terminate'
/>[/HTML]
Nov 19 '07 #4
eWish
971 Expert 512MB
Thank you for posting your solution! I have considered using the WIn32::GUI modules but have yet to do so.

--Kevin
Nov 19 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Mark Wilson CPU | last post: by
31 posts views Thread by surfunbear | last post: by
reply views Thread by Kirt Loki Dankmyer | last post: by
13 posts views Thread by Otto J. Makela | last post: by
6 posts views Thread by surfivor | last post: by
4 posts views Thread by billb | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.