Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Re: WxPerl Login Dialog

by runrig (Abbot)
on Sep 10, 2003 at 23:02 UTC ( #290550=note: print w/replies, xml ) Need Help??

in reply to Re: WxPerl Login Dialog
in thread WxPerl Login Dialog

Thanks for your comments. As you may guess, I've barely started with Wx, so I didn't even notice Wx::Dialog yet :-) Now that I've tried it, there seems to be a problem with not creating any top level window within Wx::App::OnInit. I have this:
sub OnInit { my $self = shift; $$cancel = LoginWindow->new( $user, $passwd, undef, # Parent window -1, # Window id 'Login', # Title [200,200], # position X, Y [200,150], # size X, Y wxCAPTION | wxSYSTEM_MENU )->ShowModal; }
If ShowModal returns true, the app hangs, if it returns false, then I get this error from this code within Wx::App:
my $ret = Wx::_App::Start($this,$this->can('OnInit')); Wx::_croak( 'OnInit must return a true return value' ) unless $ret || Wx::wxMAC(); # why does OnInit always return 0 on M +ac?
In the WxWindows documentation, it says to return a false value from OnInit to exit the application. I don't know why WxPerl would require a true value; it seems like a bug to me. I think I would like to just set $$cancel and then return false from OnInit unconditionally.

Update: Ahh, if I wrap the call to the App constructor in an eval, I don't get the error message, and I can filter for that particular message in $@, but I still think returning false from OnInit should be perfectly valid.

Replies are listed 'Best First'.
Re: Re: Re: WxPerl Login Dialog
by PodMaster (Abbot) on Sep 11, 2003 at 01:51 UTC
    If ShowModal returns true, the app hangs...
    That's because you've turned control over to wxWindows, but there is nothing telling the app to die (basically, you need to $app->SetTopWindow($dialog) if you want the application to exit when the window is destroyed).

    but I still think returning false from OnInit should be perfectly valid.
    I'd say I agree with you (even though I've never had the need/urge to do that), but I suspect there might be a real good reason for this (a carp would be fine with me -- you should definetly inquire on the list).

    update: I almost forgot, it's called wxPerl, not WxPerl ;)

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      There is a perfectly good situation when you want OnInit to return false imho. I use it myself in pVoice, where I use the SingleInstanceChecker. If there is already another copy of pVoice running, I let OnInit return false, so the application dies.

      Jouke Visser, Perl 'Adept'
      Using Perl to help the disabled: pVoice and pStory

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://290550]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2018-06-22 19:42 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.