Then you will probably see your code inuse warnings; use strict;
is a very bad way of tracking names, and is causing your problem. Probably what is happening, is $ComboBoxName can't be relied on the way you are using it without strict. It is getting changed somewhere , probably in the -textvariable, and gets undefined or emptied.-textvariable => \${$ComboBoxName}, -choices => \@{$ComboBoxName."List"}, -browsecmd =>\&{"on".$ComboBoxName."ComboBoxSelect"}
I won't even bother trying to figure out the problem, because the way you are naming things goes against every good programming practice for handling variables. I'm not sure what you are trying to do in the broswecmd, but this is how I would setup your program, using a hash to store the boxes. But there seems to be a bug in this too, if you browse the lower box first it changes only itself, but if you browse the upper box first, it changes both boxes. ???? A bug? Too early on Monday morning? Weird.
#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::JComboBox; my %box; my $ScreenSize = "300x250+50+50"; my $MainScreenObject = MainWindow->new(-background =>"white"); $MainScreenObject->geometry($ScreenSize); my @TestList = ('12','123','12345'); $box{1}{'var'} = 1; $box{1}{'obj'} = createComboBox(1,5,100,50); $box{2}{'var'} = 2; $box{2}{'obj'} = createComboBox(2,15,100,150); MainLoop; sub ComboBoxSelect { my $list = shift; print "Browsing $list\n"; my @TestList1 = ('a','b','cde'); $box{$list}{'obj'}->configure(-choices => \@TestList1 ,-state => 'no +rmal'); } sub createComboBox { my($ComboBoxName,$Width,$x,$y) = @_; my $ComboBoxObject = $MainScreenObject->JComboBox( -background =>'white', -textvariable => \$box{$ComboBoxName}{'var'}, -choices => \@TestList, -browsecmd => [\&ComboBoxSelect,$ComboBoxName], -entrywidth =>$Width,)->place(-x=>$x,-y=>$y); return($ComboBoxObject); }
In reply to Re: problem with Tk::JComboBox
by zentara
in thread problem with Tk::JComboBox
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |