in reply to Re^2: Prima: How to get a "table" layout?
in thread Prima: How to get a "table" layout?

In Tk I would use the 'grid' geometry manager, like the following example.

I don't have Prima on my machine, but I noticed in CPAN that there is a Prima::Grid. Perhaps it is similar.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11163718 use warnings; use Tk; my $mw = MainWindow->new(); $mw->configure(-title=> "Configuration"); my ($refreshRate, $spectralRes, $showSpectrumHz); my @tableConfig = ( ['Refresh rate:','60',\$refreshRate,'FPS'], ["Spectral resolution",'10',\$spectralRes,'Hz'], ["Show spectrum up to",'5000',\$showSpectrumHz,'Hz +']); $mw->Button(-text => 'Done', -command => sub{ $mw->destroy }, )->pack(-side => 'bottom', -fill => 'x'); my $table = $mw->Frame->pack; my $row = 1; for ( @tableConfig ) { my ($label, $value, $variable, $units) = @$_; $table->Label(-text => $label, )->grid(-row => $row, -column => 1, -sticky => 'e'); $$variable = $value; $table->Entry(-textvariable => $variable, -width => 8, -justify => 'right', )->grid(-row => $row, -column => 2, -sticky => 'ew'); $table->Label(-text => $units, )->grid(-row => $row, -column => 3, -sticky => 'w'); $row++; } MainLoop(); use Text::ASCIITable; my $t = Text::ASCIITable->new({ headingText => 'Configuration' }); $t->setCols(qw(Item Value Units)); $t->addRow( [ map [ $_->[0], ${$_->[2]}, $_->[3] ], @tableConfig ] ); print $t;