Hi François,

On 21/05/15 04:31, RAPPAZ Francois wrote:
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.
The problem with xrc files is that they are not perl, so you learn nothing about wxPerl syntax. wxGlade gives you the full wxPerl syntax, it's structure leave a little to be desired, but it will teach you how to populate and use most controls quickly.

Maybe you could use a virtual machine to experiment in that you could delete afterwards. Dare I say, you could even create a Linux virtual machine, then you wouldn't have to worry about license restrictions!!
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 ?
I've only used ClientData with ListCtrls, but according to the doc it looks as though it would work with ComboBoxs as well. I can only say I haven't used it. I use the parallel hashes or arrays. I guess ClientData would be cleaner. I'm sure there are other ways to do it, but I create each list item, format it, and then add it to the listctrl.

The way I do it with Wx::ListCtrl is as follows (summarised with relevant keywords only). I'm looping round $i:

        my $attr = Wx::ListItem->new;
        $attr->SetColumn( 0 ) ;
        $attr->SetId($i ) ;
        $listctrl->InsertItem( $attr) ;
        $listctrl->SetItemData( $i, $value ) ;

Good luck,

Steve.

Reply via email to