in reply to Help with JComboBox
use strict; use warnings; use Tk; use Tk::JComboBox; use Tk::Dialog; my $form; my %choices = ( 'a'=>1, 'b'=>2, 'c'=>3 ); my $selected_1 = "a"; my $selected = "a"; my $dialog; my $testbox1; my $testbox2; CreateMainForm(); MainLoop(); sub CreateMainForm { $form = MainWindow->new(); $form->title("Test for JComboBox Problem"); $testbox1 = $form->JComboBox( -textvariable=>\$selected_1, -validate=>'match', -mode=>'editable', -relief=>'sunken', -highlightthickness=>0, ); for my $x(keys %choices) { $testbox1->addItem("$x"); } $testbox1->pack(-side=>'left'); my $button = $form->Button( -text=>"Dialog", -command=>sub{CallDialog($testbox1)} )->pack(-side=>'right'); $dialog = $form->Dialog ( -title=>"Part2 of test", -buttons=>["Submit","Cancel"],-default_button=>"Submit" ); $testbox2 = $dialog->JComboBox(-textvariable=>\$selected, -validate=>'match',-mode=>'editable', -relief=>'sunken',-highlightthickness=>0 ); for my $x(keys %choices) { $testbox2->addItem("$x"); } $testbox2->pack(-side=>'left'); } sub CallDialog { $testbox1->configure(-state=>'disabled'); my $retval = $dialog->Show( -popover=>$form, -overanchor=>'c', -popanchor=>'c'); if($retval eq "Cancel") { $testbox1->configure(-state=>'normal'); } elsif($retval eq "Submit") { $testbox1->configure(-state=>'normal'); $testbox1->setSelected($selected ); #(optional?) } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help with JComboBox
by ChrisR (Hermit) on Nov 17, 2004 at 14:25 UTC | |
by JamesNC (Chaplain) on Nov 17, 2004 at 20:56 UTC | |
by TonyDonker (Novice) on Feb 14, 2005 at 08:50 UTC | |
by JamesNC (Chaplain) on Feb 14, 2005 at 14:49 UTC | |
by rcseege (Pilgrim) on Feb 16, 2005 at 10:52 UTC | |
| |
by TonyDonker (Novice) on Feb 15, 2005 at 07:57 UTC |