in reply to Setting the minimum size of an autosized Tk widget

Here's my best guess.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11139495 use warnings; use Tk; use Tk::BrowseEntry; my $top = MainWindow->new; my $f = $top->Frame; my $c1 = $f->BrowseEntry(-label => "Misc1:", -width => 0); $c1->pack(-fill => 'x', -expand => 1); $c1->insert("end", "0"); $c1->insert("end", "LargeButWillStillFitInTopWidgetAsItExpands"); my $c2 = $f->BrowseEntry(-label => "Misc2:", -width => 0); $c2->pack(-fill => 'x', -expand => 1); $c2->insert("end", "0"); $c2->insert("end", "Large"); $c2->insert("end", "LargeEnoughToNotFitInTopWidget"); $f->Frame(-width =>160)->pack; # strut for min width... $f->pack(-fill => 'x', -expand => 1); MainLoop;

Or maybe I don't understand your problem at all.

Replies are listed 'Best First'.
Re^2: Setting the minimum size of an autosized Tk widget
by olgo (Sexton) on Dec 10, 2021 at 14:18 UTC
    Again, thanks for your effort!
    However, the proposed solution works only as long as there is just one "column" of widgets, I think.

    Now realizing that my minimum example was a bit too minimum... sorry about that. One thing I did not tell you about was that I am using the form geometry handler. I did not think it mattered but obviously it does.
    Basically, I am placing a number of widgets in a form, one following the other in both x and y dimensions.

    A better example of the code I am struggling with is thus the following (still minimized - single line of 2 BrowseEntrys here) code example (courtesy of tybalt89):
    use strict; use warnings; use Tk; use Tk::BrowseEntry; my $top = MainWindow->new; my $f = $top->Frame; my $c1 = $f->BrowseEntry(-label => "Misc1:", -width => 0); $c1->form(-fill => 'x'); $c1->insert("end", "0"); $c1->insert("end", "LargeButWillStillFitInTopWidgetAsItExpands"); my $c2 = $f->BrowseEntry(-label => "Misc2:", -width => 0); $c2->form(-fill => 'x', -left => $c1); $c2->insert("end", "0"); $c2->insert("end", "Large"); $c2->insert("end", "LargeEnoughToNotFitInTopWidget"); $f->Frame(-width =>160)->form(); # strut for min width... $f->pack(-fill => 'x', -expand => 1); MainLoop;

      Simply strut each BrowseEntry, then...

      #!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11139495 use warnings; use Tk; use Tk::BrowseEntry; my $top = MainWindow->new; my $f = $top->Frame; my $f1 = $f->Frame->form(-fill => 'x'); $f1->Frame(-width => 150)->pack; # strut my $c1 = $f1->BrowseEntry(-label => "Misc1:", -width => 0, )->pack(-fill => 'x', -expand => 1); $c1->insert("end", "0"); $c1->insert("end", "LargeButWillStillFitInTopWidgetAsItExpands"); my $f2 = $f->Frame->form(-fill => 'x', -left => $f1); $f2->Frame(-width => 150)->pack; # strut my $c2 = $f2->BrowseEntry(-label => "Misc2:", -width => 0, )->pack(-fill => 'x', -expand => 1); $c2->insert("end", "0"); $c2->insert("end", "Large"); $c2->insert("end", "LargeEnoughToNotFitInTopWidget"); $f->pack(-fill => 'x', -expand => 1); MainLoop;