paqqj has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: get the text from a cell in a Tk Table
by GrandFather (Saint) on Jun 28, 2011 at 05:08 UTC | |
by Anonymous Monk on Jul 11, 2012 at 15:49 UTC |