First , put at the top of your script:
use warnings; use strict;
Then you will probably see your code in
-textvariable => \${$ComboBoxName}, -choices => \@{$ComboBoxName."List"}, -browsecmd =>\&{"on".$ComboBoxName."ComboBoxSelect"}
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.

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); }

I'm not really a human, but I play one on earth Remember How Lucky You Are

In reply to Re: problem with Tk::JComboBox by zentara
in thread problem with Tk::JComboBox by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.