in reply to Tk autosizing Scrolled widgets

If I understand your question (and I'm pretty sure I don't), you are trying to make a grid of widgets that has a fixed minimum size but will expand as the main window expands. I don't think you really want to put the grid in a HList because that's for hierarchical lists like directories, not grids. Here's a grid based Tk app that does what I think you want.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11136705 use warnings; use Tk; use Tk::Pane; my $mw = MainWindow->new(); $mw->geometry("+0+0"); $mw->maxsize(1000,1200); $mw->minsize(400,300); my $scroll = $mw->Scrolled('Pane', -scrollbars => 'osoe', -sticky => 'news', )->pack(-expand => 1, -fill => 'both'); my $f = $scroll->Frame->pack(-expand => 1, -fill => 'both'); foreach my $row (0..10) { foreach my $col (0..12) { $f->Entry( -text => "rc $row $col", -width => 0, )->grid(-row => $row, -column => $col, -sticky => 'news'); $row or $f->gridColumnconfigure($col, -weight => 1); } $f->gridRowconfigure($row, -weight => 1); } MainLoop;

Replies are listed 'Best First'.
Re^2: Tk autosizing Scrolled widgets
by Marshall (Canon) on Sep 13, 2021 at 23:44 UTC
    Perhaps I have misunderstood the OP's requirements?
    But your code should work with:
    #$mw->maxsize(1000,1200); #$mw->minsize(400,300);
    If I understood correctly, the idea is to size the window so that all data can be shown without scrollbars, if possible.

    Update: Your code is interesting. I'm not sure either one of us really understands the OP's requirement.

    Update2: Now that I look at your code vs mine... The main difference is that I use pack() instead of grid(). With weird shaped GUI regions, pack() tends to work better as long as you are using enough frames. In general with more than one object, you put them into a Frame and than pack that frame into a frame. Grid() is different and I haven't used it. But this can work well if every row is the "same" (i.e., lining up the columns).

    The main thing appears to be that the OP will need to calculate desired width size and then use that value to configure the window.