in reply to how to get selected value of jbrowseEntrycombo box
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::DialogBox; use Tk::JComboBox; # example by grandfather of perlmonks.org # shows how to make the textvariable ref update # see other example my $main = MainWindow->new (-title => "Test JComboBox"); EditPlayers ($main); sub EditPlayers { my ($main, $sel) = @_; my @ids = qw(Fred Joe Bob); my $dlg = $main->DialogBox (-title => "Member Information", -butto +ns => ["OK", "Cancel"]); my $id = $sel || (@ids && $ids[0]) || ''; my $IDText = $dlg->add ( 'JComboBox', -mode => 'readonly', -selectcommand => [\&changeEditPlayer, \$id], -validate => 'match', -textvariable => \$id, ); $IDText->form (-left => '%0', -right => '%100', -top => '%0'); $IDText->configure (-options => \@ids); #$IDText->setSelected ($id); # dosn't work $IDText->setSelected ($sel || (@ids && $ids[0]) || ''); #works return if $dlg->Show (-global) ne 'OK'; } sub changeEditPlayer { my ($id, $widget, $index, $value, $name) = @_; return 1 if ! defined $name; print "$name\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to get selected value of jbrowseEntrycombo box
by Sandy (Curate) on May 05, 2009 at 19:06 UTC | |
by zentara (Cardinal) on May 06, 2009 at 18:38 UTC |