From: luksedj t. f. <lu...@ya...> - 2007-03-20 09:34:32
|
Hello,=0A=0AI'm just starting to use Win32::GUI and I can't seem to explain= the behavior of my application.=0A=0AI have a main perl program that occas= ionally needs user input. On those occasions I call a function (sub) that b= uilds the window and starts the dialog, and returns a result gathered from = the user input.=0A=0AThe first time this function is called, it works as ex= pected. The user clicks a button, the button callback sets a value, and ter= minates the Dialog(). The value that was set is the return value of the fun= ction.=0A=0AHowever, on the second and following times that the function is= called, the window is shown, via printouts I can see the return value bein= g set, but when the dialog exits and the function is about to return its re= turn value, the return value is the default one, in stead of the set one. I= assume that it has to do something with me, coding the event handlers insi= de the function that does all the gui stuff. If that is so, can someone exp= lain this behavior? I don;t mind changing my code, but then I want to under= stand why it behaves like this.=0A=0AThe code is pasted below. The behavior= I want is that the user clicks on the pass button which returns 1 to the c= alling function. If you press 'passed' in every test, then you'll see the r= eturn value is 0 starting from the second call to the 'verify' function.=0A= =0A=0Ause Win32::GUI();=0A=0A=0A=0Amy $canvas_height =3D 328;=0Amy $title_h= eight =3D 32;=0Amy $margin =3D 15;=0A=0A=0Afor ($i=3D0; $i<5;$i++){=0A m= y $output =3D "test $i";=0A print "$output ";=0A my $result_1 =3D ver= ify($output);=0A print $result_1;=0A print " $output\r\n";=0A}=0A = =0A=0Asub verify {=0A my $output =3D shift;=0A =0A my $result =3D = 0;=0A my $main =3D=0A Win32::GUI::DialogBox->new(=0A = -name =3D> 'Main',=0A -width =3D> 280,=0A = -height =3D> $canvas_height+$title_height,=0A = -text =3D> 'Test Step Output Verification',=0A -helpbo= x =3D> 0,=0A );=0A =0A =0A my $outputfield =3D $= main->AddTextfield(=0A -name =3D> 'Outputfield',=0A = -multiline =3D> 1,=0A -hscroll =3D>= 1,=0A -vscroll =3D> 1,=0A -width= =3D> 215,=0A -height =3D> 200,=0A = -pos =3D> [ $margin, 60],=0A -disabled =3D> 0,=0A = -readonly =3D> 1,=0A );=0A =0A = my $pass =3D $main->AddButton(=0A -text =3D> 'Passed',=0A = -width =3D> 100,=0A -height =3D> 25,=0A = -pos =3D> [$outputfield->Left(),=0A $outputfi= eld->Height() + $outputfield->Top() + $margin],=0A -name =3D= > 'Pass',=0A -tabstop =3D> 1=0A );=0A =0A = my $fail =3D $main->AddButton(=0A -text =3D> 'Failed',= =0A -width =3D> 100,=0A -height =3D> 25,= =0A -pos =3D> [$outputfield->Left() + $outputfield->Widt= h() - 100,=0A $pass->Top()],=0A -nam= e =3D> 'Fail',=0A -tabstop =3D> 1=0A );=0A= =0A =0A sub Pass_Click {=0A $result =3D 1;=0A $output= field->Text("result : $result");=0A -1;=0A }=0A =0A sub Fail_= Click {=0A $result =3D 0;=0A $outputfield->Text("result : $result= ");=0A -1;=0A }=0A =0A sub Main_Terminate {=0A -1;=0A }= =0A =0A =0A $outputfield->Text($output);=0A $main->Show();=0A = Win32::GUI::Dialog();=0A return $result;=0A}=0A=0A=0AThanks for any hi= nts,=0A=0Aluksedj=0A=0A=0A=0A=0A =0A_______________________________________= _____________________________________________=0AExpecting? Get great news r= ight away with email Auto-Check. =0ATry the Yahoo! Mail Beta.=0Ahttp://advi= sion.webevents.yahoo.com/mailbeta/newmail_tools.html |