Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Prima: How to get a "table" layout?

by tybalt89 (Monsignor)
on Jan 19, 2025 at 18:36 UTC ( [id://11163748]=note: print w/replies, xml ) Need Help??


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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11163748]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2025-11-13 02:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (68 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.