From: DanielMS <dan...@ya...> - 2006-09-10 20:01:16
|
So i did some steps forward but now I have some more questions, I think for you it is only a little thing but unfortunally not for me. So if you can give me a hint, you would make me happy. I have marked the lines in the code http://www.nabble.com/user-files/235940/test1.pl test1.pl with "Question:..." In line 23 I use the wxPerl Icon. How can I use my own one (png-Iconfile)? In line 139 I want to use the Wx::PasswordEntryDialog but it seems not to be available. Why? I use only one function for all buttons when pressed. So how can i figure out, which one caused the event (line 163)? Thats all for now. Thank you! Regards Daniel -- View this message in context: http://www.nabble.com/Some-more-Questions-tf2248962.html#a6237396 Sent from the wxperl-users forum at Nabble.com. |
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 |
From: DanielMS <dan...@ya...> - 2006-09-12 21:25:03
|
Hi Mark, thank you for your answer. In the meantime I changed my code to somthing like this for each button: #----------------------------------------------------------- EVT_BUTTON($panel, $panel->{button}{"pl_button"}, sub {=20 =20 my $anzahl =3D $rightchecklistbox->GetCount(); my @items; =20 for (0..$anzahl) { #der gr=C3=B6=C3=9Fte Index zuerst, damit das l=C3= =B6schen funktioniert unshift(@items,$_) if $rightchecklistbox->IsChecked($_);=20 } =20 foreach (@items) { $rightchecklistbox->Delete($_) } =20 $self -> SetStatusText("Pakete wurden aus der Liste gel=C3=B6scht!"); =20 } ); #----------------------------------------------------------- Therefore I had to create the buttons like that: #----------------------------------------------------------- $panel->{button}{"pl_button"} =3D Wx::Button->new( $panel, # parent window .... #----------------------------------------------------------- I'm not sure of what exactly means $panel->{button}{"pl_button"} but it works fine! I found this in another sample programm. PW-Dialog works! But as far as I understand the wxwindows doc, the common dialogs have only one text entry field, is that right? So if I need a dialo= g for username and pw, I have to create it on my own?=20 The other thing with the icon I will try later. best regards Daniel --=20 View this message in context: http://www.nabble.com/Some-more-Questions-tf2= 248962.html#a6274707 Sent from the wxperl-users forum at Nabble.com. |
From: Mark D. <mar...@zn...> - 2006-09-12 22:21:21
|
Hi Daniel DanielMS wrote: > Hi Mark, > I'm not sure of what exactly means $panel->{button}{"pl_button"} but it > works fine! I found this in another sample programm. That's perl 'auto instancing' for you. $panel is a reference to (I assume) a panel object which is a perl hash and panel class. So I could do: $panel->{myvalue} = 1; $panel->{myothervalue} = 2; and the keys 'myvalue' and 'myothervalue' would be paired with the values 1 & 2 in my hash. if I do $panel->{another}{thing} = 5; then perl works out that I want the key 'another' in my panel hash to be paired with an anonymous hash, and I want the key 'thing' in that second hash to be paired with the value 5; So: $panel->{button}{plbutton} = Wx::Button->new(....); just means that $panel->{button}{plbutton} is exactly the same as above except that the value held is a Wx::Button object. $panel->{x}{y} = Wx::Button->new(....); would work exactly the same. If you are just starting out with Perl, not just wxPerl, I think you will find wxPerl quite difficult to get to grips with just from example code - not least because Perl allows you to do everything in 101 different ways. Its hard work at first, but you just have to read the 'perldocs'. Once you are comfortable with how hashes, arrays and references work in perl, you'll find wxPerl much easier to progress with. Good luck - and don't give up! best regards Mark |