From: Peter E. <Pet...@at...> - 2002-08-26 17:56:41
|
The subs are called by events, such as Click, RightClick, etc. Any = handle such as Hello (which in this case is defined as the name of the button) = can have one or more of these actions assigned to them. The convention for = these subs is Name_Event where _Event is appended to the widget's name, i.e. Hello_Click is run when Hello (the button) gets a single click from the user. HTH, Pete > -----Original Message----- > From: Gossett, Malachy [mailto:mal...@ve...] > Sent: Monday, August 26, 2002 13:33 > To: per...@li... > Subject: RE: [perl-win32-gui-users] first app ? >=20 >=20 > Johan, that is a pretty good explanation. I'm a bit new to=20 > Win32::GUI, > having used TK more, but never became a super user with it=20 > either. Once > question I have, I notice that subroutines don't need=20 > specific calls, so > how do they get called. >=20 > A perfect example would be the hello.pl from th 665 source=20 > release. How > are the subroutines being called in this? >=20 > Thanks >=20 > Mal >=20 > use Win32::GUI; > $MW =3D new Win32::GUI::Window( > -title =3D> 'hello.pl', > -left =3D> 100, > -top =3D> 100, > -width =3D> 150, > -height =3D> 100, > -name =3D> 'MainWindow', > -visible =3D> 1, > ); >=20 > #Add controls > my $label =3D $MW->AddLabel(-text =3D> "This is my text.",=20 > -font =3D> $font); >=20 > $hello =3D $MW->AddButton( > -text =3D> 'Hello, world', > -name =3D> 'Hello', > -left =3D> 25, > -top =3D> 25, > ); >=20 > $MW->Show(); > $rc =3D Win32::GUI::Dialog(0); >=20 > sub MainWindow_Terminate { > $MW->PostQuitMessage(1); > # return -1; > } >=20 > sub Hello_Click { > if($MW->Hello->Text eq "Hello, world") { > $MW->Hello->{-text} =3D "OneMoreTime"; > } else { > print STDOUT "Hello, world\n"; > $MW->PostQuitMessage(0); > } > } >=20 >=20 > -----Original Message----- > From: Johan Lindstrom [mailto:jo...@ba...]=20 > Sent: Monday, August 26, 2002 10:21 AM > To: per...@li... > Subject: Re: [perl-win32-gui-users] first app ? >=20 >=20 > At 08:03 2000-08-27 +0300, ra...@un... wrote: > >I've just installed win32::gui but how i will do my first=20 > app if I try=20 > >this : > > > >use Win32::GUI; > >my $w =3D new Win32::GUI(-name =3D> 'XX'); > >$w->Show(); > > > >But the window just got created and destroyed imedietly !?! Why this = > >happen ? >=20 > Unlike your vanilla Perl program, most event based programs=20 > run what's=20 > called a main event loop. A GUI is most often event based. It=20 > means that >=20 > you start it, and then it sits there waiting for user input (events, > like=20 > mouse clicks on buttons, or timers being triggered). >=20 > In Win32::GUI, you enter the main loop by calling=20 > Win32::GUI::Dialog(), > so=20 > you should add that to your program, after the Show(). >=20 > Before entering the main loop you should have created all your = windows > (and=20 > Show():ed the ones you want visible from the beginning). In most = cases > you=20 > should never call Win32::GUI::Dialog() more than once in your = program. >=20 > After you call Win32::GUI::Dialog(), the only way to exit is from an > event.=20 > This happens when an event handler returns -1. Typically, the=20 > Terminate=20 > event handler of your application window should return -1. In=20 > your case: >=20 > sub XX_Terminate { > return(-1); > } >=20 > In other cases, you want to Hide() the window (and return 0) in the=20 > Terminate event handler instead, so you can Show() it again at a = later > time. >=20 >=20 > /J >=20 > -------- ------ ---- --- -- -- -- - - - - - > Johan Lindstr=F6m Sourcerer @ Boss Casinos jo...@ba... >=20 > Latest bookmark: "Salon.com Technology I come to bury IAmCarbona..." > <http://www.salon.com/tech/feature/2002/08/03/deleteddomains/i ndex.html> dmoz (1 of 13): /Computers/Internet/On_the_Web/Weblogs/Tools ------------------------------------------------------- This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE! https://www.inphonic.com/r.asp?r=3Dsourceforge1&refcode1=3Dvs3390 _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users ------------------------------------------------------- This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE! https://www.inphonic.com/r.asp?r=3Dsourceforge1&refcode1=3Dvs3390 _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users |