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/-pad etc. options.

🌈 SEE ALSO 🌈

go read these next, bestie:

  • Tk::grid
  • Tk::HList
  • Tk::TableMatrix
  • Tk::MListbox
  • Tk::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