Howdy! I would like to "get" the text that is in a Tk table. The table is 2 columns and 8 rows, and I'd like to "get" what is in one of the cells.

What I want is:

The stuff that is in box (2,2) is SOME TEXT.

But what I get is:

The stuff that is in box (2,2) is Tk::LabEntry=HASH(0x8a74ff0)

#!/usr/bin/perl # # wid2.pl # $|=1; use Tk; require Tk::LabFrame; require Tk::LabEntry; require Tk::Table; my $mw = MainWindow->new; $mw->geometry("+400+400"); my $LaLo = $mw->LabFrame(-label => "LaLo", -labelside => "acrosstop"); $LaLo->form(-top => '%0', -left => '0', -bottom => '%100'); my $table_frame = $LaLo->Frame()->pack(); my $table = $table_frame->Table(-columns => 2, -rows => 10, -fixedrows => 1, -scrollbars => 'oe', -relief => 'raised'); my $tmp_label = $table->Label(-text => "LAT" , -width => 8, -relief +=>'raised'); $table->put(0, 1, $tmp_label); my $tmp_label = $table->Label(-text => "LONG" , -width => 8, -relief + =>'raised'); $table->put(0, 2, $tmp_label); #generate the 2x8 table and put blank space in each one foreach my $row (1 .. 8) { foreach my $col (1 .. 2) { $tmp_label = $table->LabEntry(-text => "", -background => 'white', -relief => "groove"); $table->put($row, $col, $tmp_label); } } # Now put a value in one of them $tmp_label=$table->LabEntry(-text=>"SOME TEXT GOES HERE"); $table->put(2,2,$tmp_label); ###################################################################### +#### # This is the part that doesn't work right $THE_STUFF_THAT_IS_IN_BOX_2_2=$table->get(2,2); print "The stuff that is in box (2,2) is $THE_STUFF_THAT_IS_IN_BOX_2_2 +\n"; ###################################################################### +#### $table->pack(); MainLoop;

In reply to get the text from a cell in a Tk Table by paqqj

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.