in reply to Prima: How to get a "table" layout?
Adjusting cells height per row and, thus, simulating a table isn't too difficult, but perhaps what follows has its own hidden drawbacks. Thanks for reminding about Prima and GUIs in general, nice time it was.
use strict; use warnings; use feature 'say'; use Prima qw(Application Label InputLine); # use Prima::Stress; my $main = Prima::MainWindow-> create( text => 'Configuration', backColor => cl::White, menuItems => [ ['~File' => [['~Quit' => 'Ctrl+Q', '^Q', sub { $::application->close } ], ], ], ] ); $main-> hide; my $table = $main-> insert( Widget => pack => { side => 'top' }, ); my @cols = map $table-> insert( Widget => pack => { side => 'left', anchor => 'n' }, ), 0 .. 1; # let's pretend columns do have different scale $cols[ 1 ]-> font({ size => 5 + $cols[ 0 ]-> font-> size }); for ( 0 .. 9 ) { my $label = $cols[0]-> insert( Label => text => substr( 'Label 1234567890', 0, 7 + $_ ) . ': ', pack => { side => 'top', anchor => 'e' }, ); my $input = $cols[1]-> insert( InputLine => text => '12345', pack => { side => 'top' }, ); my $h_L = $cols[0]-> height; my $h_IL = $cols[1]-> height; if ( $h_L > $h_IL ) { $input-> pack( pady => $h_L - $h_IL ) } else { $label-> pack( pady => $h_IL - $h_L ) } } $main-> show; Prima-> run;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Prima: How to get a "table" layout?
by haj (Vicar) on Jan 19, 2025 at 23:16 UTC |