in reply to Prima: How to get a "table" layout?
In Tk there is a "Frame" widget which usually has invisible borders. Things inside of a Frame widget get grouped. In the example below, there is a text label on the left; all of them are stuffed into a Frame. And then within that Frame, they are right justified and anchored to the east. The Frame will expand to accommodate the longest label.
In Prima, I see that there is a FrameSet gizmo. This may get you similar function to a Tk Frame.
Run this and let us know how close it is to your requirements.
Added:
I did set one width manually, the input field width, I forget what the units are but you can play around with it.
se warnings; use strict; use Tk; my $mw = MainWindow->new(); $mw->configure(-title=> "Some Title"); $mw->minsize(qw(700 200)); my $mainDataFrame = $mw->Frame()->pack(-side=>'top', -fill=>'x'); my $labelFrame = $mainDataFrame->Frame->pack(-side=>'left'); my $dataEntryFrame = $mainDataFrame->Frame->pack(-side=>'left'); my $unitsFrame = $mainDataFrame->Frame->pack(-side=>'left'); my $refreshRate; my $spectralRes; my $showSpectrumHz; my @tableConfig = ( ['Refresh rate:','60',\$refreshRate,'FPS'], ["Spectral resolution",'10',\$spectralRes,'Hz'], ["Show spectrum up to",'5000',\$showSpectrumHz,'Hz +']); for my $rowRef ( @tableConfig ) { $labelFrame->Label(-text => "$rowRef->[0]", -anchor=>'e', -justify => 'right')->pack(-side=>'top', -fill +=> 'x'); my $dataRef = $rowRef->[2]; # put default value into textvariable $$dataRef = $rowRef->[1]; $dataEntryFrame->Entry(-width => 8, -textvariable => $dataRef, )->pack(-side =>'top', -fill => 'x'); $unitsFrame->Label(-text => "$rowRef->[3]", -anchor=>'w', -justify => 'left')->pack(-side=>'top', -fill = +> 'x'); } MainLoop();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Prima: How to get a "table" layout?
by haj (Vicar) on Jan 19, 2025 at 10:15 UTC | |
by tybalt89 (Monsignor) on Jan 19, 2025 at 18:36 UTC | |
by Marshall (Canon) on Jan 19, 2025 at 17:53 UTC | |
by haj (Vicar) on Jan 19, 2025 at 22:41 UTC | |
by Marshall (Canon) on Jan 22, 2025 at 04:59 UTC |