That is happening because of the way the BrowseEntry widget handles mouse clicks.

Mouse button 1 clicks outside of a BrowseEntry selection choice list clears the current selection. So only the last BrowseEntry you adjust will (possibly) still have a curselection list.

I'm not sure exactly what you are trying to accomplish, but it seems like you are doing an awful lot of unnecessary work. Would something like this do what you want?

use strict; use warnings; use Tk; my $textboxrow = 1; my $fieldbuttonrow = 2; my @be; my $mw = tkinit; $mw -> geometry("400x200"); my $button = $mw->Button(-text => 'Add Field', -command => \&addtext +box); my $button2 = $mw->Button(-text => 'Print texts',-command => \&printte +xts); addtextbox(); MainLoop(); sub addtextbox{ my $be = $mw->BrowseEntry(-label=>"Field"); $be->insert('end', $_) for qw/dog cat mouse/; push @be, $be; $be ->grid(-row=>$textboxrow++, -column=>2); $button ->grid(-row=>$fieldbuttonrow++,-column=>2,-columnspan=>2); $button2->grid(-row=>$fieldbuttonrow ,-column=>2,-columnspan=>1); } sub printtexts{ print join ':', map { $_->Subwidget('entry')->get } @be; }

In reply to Re: perltk: error getting values from dynamically generated combo boxes by thundergnat
in thread perltk: error getting values from dynamically generated combo boxes by ruhroh

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.