> winfo reqwidth/height on the frame once populated and after an update
idletasks may give you the right size.  > Make sure you check for
reasonable maximums though.

I don't understand how to use reqwidth and reqheight.  They return the
'requested' width and height, which seems to always be 396, 282 for a
window.  Can you explain how it would work?  Here's sample code that
tries using reqwidth/reqheight and also width/height.  Width/height
simply returns the current size, which if the window is stretched or
shrunk will be different from 396, 282.

Dave


use strict;
use Tkx;
Tkx::package_require("tile");
Tkx::package_require("BWidget");

my $mw = Tkx::widget->new(".");
my $sw = $mw->new_ScrolledWindow();
my $sf = $sw->new_ScrollableFrame();

$sw->setwidget($sf);
$sw->g_grid(-row => 0, -column => 0, -sticky => "nsew");

Tkx::grid(rowconfigure => $mw, 0, -weight => 1);
Tkx::grid(columnconfigure => $mw, 0, -weight => 1);

# This is the one tricky conversion.  We are getting a widget ref
# back from Tcl that has never been seen as a widget in Tkx, thus
# the Tkx::widget call makes the right kind of object.
my $subf = Tkx::widget->new($sf->getframe());

my $b;
for my $row (1..20) {
    for my $col (1..20) {
        $b = $subf->new_ttk__button(-text => "$row,$col",
                        -command => sub { exit(); });
        $b->g_grid(-row => $row, -column => $col);
    }
}

$b = $subf->new_ttk__button(-text => "reqwidth", -command =>
\&Reqwidth);
$b->g_grid(-row => 0, -column => 1);

$b = $subf->new_ttk__button(-text => "width", -command => \&Width);
$b->g_grid(-row => 0, -column => 2);

Tkx::MainLoop;

sub Reqwidth
{
    my $width = Tkx::winfo('reqwidth', $mw);
    my $height = Tkx::winfo('reqheight', $mw);
    print "reqwidth: $width, reqheight: $height\n";
    $mw->g_wm_geometry($width . "x" . $height . "+50+50");
}

sub Width
{
    my $width = Tkx::winfo('width', $mw);
    my $height = Tkx::winfo('height', $mw);
    print "width: $width, height: $height\n";
    $mw->g_wm_geometry($width . "x" . $height . "+50+50");
}

Reply via email to