From: Mark D. <mar...@zn...> - 2006-09-12 19:53:25
|
Hi Daniel DanielMS wrote: > In line 23 I use the wxPerl Icon. How can I use my own one (png-Iconfile)? I'm not entirely sure of which icon types are OK on which playforms. According to docs PNG is only supported on wxGTK, but I'm sure I've used them on wxMSW? Anyhow, depending on your platform one or both of the following should work: $self->SetIcon( Wx::Icon->new('pathtomypng.png', wxBITMAP_TYPE_PNG) ); $self->SetIcon( Wx::Icon->new('pathtomyico.ico', wxBITMAP_TYPE_ICO) ); > > In line 139 I want to use the Wx::PasswordEntryDialog but it seems not to be > available. Why? Not all the functions from wxWidgets are wrapped. This is often because functions are duplicated or there are better alternatives in perl. In this case, you need: #----------------------------------------------------------- my $dialog = Wx::TextEntryDialog->new ( $this, "Enter Your Password", "Wx::TextEntryDialog Password Example", "", wxOK|wxCANCEL|wxCENTRE|wxTE_PASSWORD); if( $dialog->ShowModal == wxID_CANCEL ) { Wx::LogMessage( "User cancelled the dialog" ); } else { Wx::LogMessage( "Password !: %s", $dialog->GetValue ); } $dialog->Destroy; #----------------------------------------------------------- By the way - wxDemo, downloadable or browseable in CVS, contains many examples which will probably answer most of your questions about wxPerl > I use only one function for all buttons when pressed. So how can i figure > out, which one caused the event (line 163)? An event object has a function 'GetId' which in the case of EVT_BUTTON returns the button ID. (my $buttonid = $event->GetId(); ) You can either use a known ID when you create your button (instead of passing '-1', or you could call $button->GetId() just after creation and perhaps store the value in a hash for later lookup in your event handler. >From much of the example code I have seen, it seems to be common practice not to do this and to attach the EVT_BUTTON for each button to a separate event handler. If you want to create buttons 'dynamically' at runtime, then perhaps an OO approach would be much neater. Create a base class for your buttons deriving from Wx::Button. Handle the button click event initially inside your button class - so every button click calls the handler in its own instance. Best regards Mark |