Hi there,

Steve, Thanks for the example and the urls. I'm on W7 and I didn't want to 
install Python + wxPython, so I'm using wxFormBuilder to produce xrc files that 
I load with perl.

Using an array (or an hash with id/position in the combo) that shadows the 
combox content works, but I would like to associate the id with combo using 
client data. 

In my code

$w holds a Wx::ComboBox ref.
If I loop through the id and the names I want to show in the combo:

  $w->Append($displayedValue); # string for position $i
  $w->SetClientData($i, $value); #$value is what I want retrieve from the 
selection

But 

Print Dumper $w->GetClientData($i)); return undef

What am I missing ? Is there some lines of working code somewhere ?

Thanks

François



> -----Original Message-----
> From: Steve Cookson - gmail [mailto:steveco.1...@gmail.com]
> Sent: mardi, 19. mai 2015 16:21
> To: RAPPAZ Francois
> Cc: wxperl-users@perl.org
> Subject: Re: Help with Wx::Perl::PubSub
> 
> Hi François,
> 
> On 19/05/15 07:55, RAPPAZ Francois wrote:
> > Another question: I would like to have a dropdbox that list usernames
> and that return a userid when one select a name. Shall I use a
> Wx::ListBox or Wx::ListCtrl ?
> > Can you point me to some codes examples ?
> I would use wx::combobox (here:
> http://docs.wxwidgets.org/trunk/classwx_combo_box.html).  I don't
> recall if it has a a client data attribute like listctrl, if not you
> can always use an indexed array like this:
> 
> @combo_options = ("Andy", "Bob", "Charlie", "Dave", "Edward",
> "François"); # User names @userid = ("a_smith", "r_smith", "c_smith",
> "d_smith", "e_smith", "f_rappaz); # User ids
> 
> Wx::ComboBox->new($self->{$parent, -1, "", wxDefaultPosition,
> wxDefaultSize, \@combo_options, wxCB_DROPDOWN|wxCB_READONLY|wxCB_SORT);
> 
> .
> .
> .
> .
> 
>      $userid_selected=$userid[$combobox->GetSelection()];
> 
> There's so much code in cpan -i Wx::Demo for everything.  Otherwise
> people have put various tutorials on PerlMonks.  Here are some other
> links:
> 
> http://wxperl.sourceforge.net/tutorial/tutorial.html
> http://learnperl.scratchcomputing.com/tutorials/wxperl/
> http://wiki.wxperl.nl/Main_Page
> http://www.perlmonks.org/?node_id=112297
> http://examples.wxperl.it/
> http://www.perl.com/pub/2001/09/12/wxtutorial1.html
> http://padre.perlide.org/learning-wxperl-and-wxwidgets.html
> 
> Oh and I almost forgot, wxGlade (apt-get install python-wxglade) will
> produce wxPerl code for you, although I don't know if it has been
> upgraded for 3.0.x.  I used it to to build most of my early screens.
> At least it will get your syntax right.
> 
> Good luck,
> 
> Steve.

Reply via email to