RE: Scrolled frame or pane ?

[email protected] ("Swingle David-QWHM86")
Newsgroups perl.tcltk
Message-ID <[email protected]>
Hi Jeff,

See the related post, "Scrolling a window", and the following code.
With other's help the below code works for me.  Hopefully it helps you.

-- dss


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

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

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);
    }
}

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

foreach (Tkx::SplitList($mw->g_winfo_children))
{
    Tkx::grid_configure($_, -padx => 2, -pady => 2);
}

Tkx::update('idletasks');
#Tkx::wm_geometry($mw,
#    Tkx::winfo_reqwidth($subf) . "x" . Tkx::winfo_reqheight($subf));
Tkx::wm_geometry($mw, (Tkx::winfo('reqwidth', $subf) + 10) . "x" .
    (Tkx::winfo('reqheight', $subf) + 10));

Tkx::MainLoop;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.