Table(3pm)
π Table β bestie edition π
okay so we're talking about Tk::Table, from the User Contributed Perl Documentation section of the perl/Tk manual pages (the 3pm girlies know). It's a scrollable 2 dimensional table of Tk widgets. yes really. that's the whole vibe. π
β¨ NAME β¨
Tk::Table β Scrollable 2 dimensional table of Tk widgets π¦
β¨ SYNOPSIS β¨
okay bestie, here's how you actually summon her:
use Tk::Table;
$table = $parent->Table(-rows => number,
-columns => number,
-scrollbars => anchor,
-fixedrows => number,
-fixedcolumns => number,
-takefocus => boolean);
$widget = $table->Button(...);
$old = $table->put($row,$col,$widget);
$old = $table->put($row,$col,"Text"); # simple Label
$widget = $table->get($row,$col);
$cols = $table->totalColumns;
$rows = $table->totalRows;
$table->see($widget);
$table->see($row,$col);
($row,$col) = $table->Posn($widget);
like. she's giving geometry manager. she's giving widget parent. she's giving everything. π«Ά
β¨ DESCRIPTION β¨
so Tk::Table is an all-perl widget/geometry manager that lets you display a two dimensional table of arbitrary perl/Tk widgets. any widgets. your widgets. no cap. π
Entries in the Table are literally just ordinary perl/Tk widgets β nothing fancy, nothing cursed. They should be created with the Table as their parent. And then you position them in the table using:
$table->put($row,$col,$widget)
and here's the cute part: if $widget is not a reference, it gets treated as a string, and a Label widget gets created with that string as its text. so you can just throw text in there and she'll handle it. iconic. β¨
π sizing behavior (the way she aligns things)
All the widgets in each column are set to the same width β specifically the requested width of the widest widget in the column. Likewise, all the widgets in each row are set to the same height β the requested height of the tallest widget in the column.
π fixed rows and columns
A number of rows and/or columns can be marked as 'fixed' β and so can serve as 'headings' for the remainder the rows which are scrollable. so like, sticky headers but make it Tk. π§
π requested size
The requested size of the table as a whole is such that the number of rows specified by -rows (default 10) and the number of columns specified by -columns (default 10) can be displayed. defaults go crazy fr fr. πΈ
π keyboard focus
If the Table is told it can take the keyboard focus, then cursor and scroll keys scroll the displayed widgets. keyboard girlies, this one's for you. π
π -scrollbars
By default, scrollbars will be added "nw". To disable scrollbars, set -scrollbars to an empty string:
$table = $parent->Table(-scrollbars => '', ...);
not me turning off the scrollbars π
π clearing the table
The table can be emptied using
$table->clear
β οΈ heads up bestie: the widgets which were in the table are destroyed. gone. deleted. not coming back. π
π inheritance
The Tk::Table widget is derived from a Tk::Frame, so it inherits all its configure options. family money. π
π focus traversal
The default focus traversal is giving the focus only to the table widget as a whole. To enable focus traversal into table cells (e.g. if there are embedded entry widgets), then the option -takefocus has to be set to 0.
yes, set it to 0 to get more focus traversal. that's not a typo, that's just how she is. π
π BUGS / Snags / Possible enhancements π
look, she's not perfect, she's just iconic. here's the tea:
- Very large Tables consume a lot of X windows. π
- No equivalent of pack's
-anchor/-padetc. options.
π SEE ALSO π
go read these next, bestie:
Tk::gridTk::HListTk::TableMatrixTk::MListboxTk::Columns
perl v5.40.1 Β· 2025-04-13 Β· Table(3pm)
and that's the whole page, bestie π«Ά this was documented on 2025-04-13 for perl v5.40.1 in the Table(3pm) era of the perl/Tk manpages. slay, stay scrollable, and remember: your widgets get destroyed when you call clear. periodt. π
β¨
π¦ where this page comes from
- debian trixie: perl-tk 1:804.036+dfsg1-5
- ubuntu questing: perl-tk 1:804.036+dfsg1-5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms