From: Everett, T. <TEv...@AL...> - 2002-09-06 01:24:44
|
It appears that both the value parameter in the constructor and Wx::ComboBox::SetValue are ineffective when wxCB_READONLY is set. Wx::ComboBox::SetSelection continues to work. The documentation for wxComboBox::SetValue states: "NB: For a combobox with wxCB_READONLY style the string must be in the combobox choices list, otherwise the call to SetValue() is ignored." The appended code should suffice to demonstrate. And, in case I seem insufficiently grateful, wxPerl does really rock! I'm still stumbling my way through the darkness, but I'm making reasonably good progress in doing my first test port of a Tk app. There are definitely some Tk things I miss (-textvariable, for one:), but I will say the native look and feel is greatly appreciated. Oh, and here's a cute tidbit. Minimalist code for tossing up a GUI error message: require Wx; *Wx::App::OnInit = sub {1}; my $temp = Wx::App->new(); Wx::MessageBox($errormsg, "Fatal Error", wxOK|wxICON_ERROR, undef); --Toby Everett use strict; package MyFrame; use Wx qw(:everything); use vars qw(@ISA); @ISA=qw(Wx::Frame); sub new { my $class = shift; my $self = $class->SUPER::new(undef, -1, $0, [-1,-1], [-1,-1]); my $wx = $self->{wx} = {}; $wx->{pnl} = Wx::Panel->new($self, -1); $wx->{szr} = $_ = Wx::BoxSizer->new(wxVERTICAL); $wx->{pnl}->SetSizer($_); $wx->{pnl}->SetAutoLayout(1); my @list = qw(red orange yellow green blue purple); $wx->{cmbDemo} = $_ = Wx::ComboBox->new($wx->{pnl}, -1, $list[2], [-1,-1], [-1,-1], \@list, wxCB_DROPDOWN|wxCB_READONLY); $wx->{szr}->Add($_, 0, wxALIGN_CENTRE|wxALL, 5); # $wx->{cmbDemo}->SetValue($list[2]); # $wx->{cmbDemo}->SetSelection(2); $wx->{szr}->Fit($self); return $self; } package MyApp; use Wx; use vars qw(@ISA); @ISA=qw(Wx::App); sub OnInit { my $self = shift; my $frame = MyFrame->new(); $self->SetTopWindow($frame); $frame->Show(1); } package main; (my $app = MyApp->new())->MainLoop(); |