I think what you want is: When the display pops up onto the screen, it should use the entire height and width of the monitor and not have any scrollbars unless they are necessary? Since you have solved the first part of the problem (scrollbars disappear if the aren't needed). This comes down to the equivalent requirement of how to size the window so that you can see everything without scrollbars, if possible?
There isn't any pack() parameter, to my knowledge that says "use entire screen space".
I think you will have to calculate your "ideally" required space (height and width in pixels), and compare that with the pixel resolution of the monitor that you are running on. If there aren't enough pixels available, then the best that you can do is have a window of the max monitor's pixel width.
These functions are available:
It been a very long time since I worked with Tk. I'm not familiar with some of the widgets that you used, so I wrote my own example to play with.$widget->reqheight #requested height $widget->height #actual height $widget->reqwidth #requested width $widget->width #actual width
What I wanted to show is how to count up pixel widths of objects and then use that total to configure the window size. For some reason the configure method didn't work in my testing, but but I'm sure that is some kind of brain cramp on my part. I just set the minimum width of the window to size needed for the columns shown. I added a 20 pixel "fudge factor" at the end of the row to account for the scroll bars in my example which work differently than yours. I just did the width calculation, but height would be similar.
Anyway here is my hacking code for further thought..
You will of course have to figure out the pixel width of the monitor that you are running upon. But that is not a Tk function to my knowledge.use Tk; use Tk::Pane; use strict; use warnings; my $Window = MainWindow->new(); $Window->geometry("+0+0"); # start in upper left corner of display my $sframe = $Window; my $scroll = $sframe->Scrolled('Pane', -sticky => 'news', -scrollbars => 'se', ); $scroll->pack(-expand => 1, -fill => 'both');; my $total_row_width = 0; foreach my $row (0..9) { my $row_frame = $scroll->Frame()->pack(-side=>'top',-fill=>'x'); $total_row_width = 0; foreach my $col (0..12) { my $this_entry =$row_frame -> Entry(-text => "Whatever $row,$co +l", -width => 12)->pack(-side = +> 'left'); my $width_this_widget = $this_entry->reqwidth; $total_row_width += $width_this_widget; } #print "width in pixels this row of widgets: $total_row_width\n"; } my $fudge = 20; print "total row width = $total_row_width\n"; $Window->minsize($total_row_width + $fudge,300); MainLoop;
In reply to Re: Tk autosizing Scrolled widgets
by Marshall
in thread Tk autosizing Scrolled widgets
by olgo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |