> I tried a simple code to access Tk through Tcl extension but get the
> following errors.
> ___________________
> Tcl error 'invalid command name "ScrolledWindow::Pane" at 
> C:/Perl/site/lib/Tcl.pm line 548.
> ' while invoking scalar result call:
>       ".sc02 Pane" at C:/Perl/site/lib/Tcl.pm line 549
>       Tcl::call('Tcl::Tk=SCALAR(0x275294)', '.sc02', 'Pane') called at
>         C:/Perl/site/lib/Tcl/Tk.pm line 2348
>       Tcl::Tk::Widget::__ANON__('Tcl::Tk::Widget=SCALAR(0x190c574)')
>         called at C:/Perl/site/lib/Tcl/Tk.pm line 2354
>       Tcl::Tk::Widget::AUTOLOAD('Tcl::Tk::Widget=SCALAR(0x190c574)')
>         called at C:/Perl/site/lib/Tcl/Tk.pm line 2097
>       
> Tcl::Tk::Widget::Scrolled('Tcl::Tk::Widget::MainWindow=SCALAR(
> 0x1900388)', 'Pane', '-scrollbars', 'osoe')
>         called at Tcltest.pl line 13
> ___________________
> 
> Code snippet:
> use Tcl::Tk qw/:perlTk/;
> use Tk::Pane;

that line 'use Tk::Pane' have no sence if you're using Tcl::Tk module.

> use warnings;
> use strict;
> my ($mw,$pane_fr);
> $mw = MainWindow->new();
> $mw->geometry("300x100");
> $pane_fr = $mw->Scrolled('Pane',
>                        -scrollbars=>'osoe',
>                       )->pack(-fill=>'both',
>                               -expand=>1,
>                              );
> MainLoop;

This is because Tk::Pane is not ported to Tcl::Tk, however porting it is
easy.

Looking at "perldoc Tk::Pane" I see that it is very close to a widget named
"ScrollableFrame" within BWidgets
(and Tk::Panedwindow is very close to PanedWindow within same BWidgets)

To introduce 'Pane' widgets which refers to 'ScrollableFrame' you need only
one single line of code:

$mw->Declare('Pane','ScrollableFrame',-require=>'BWidget');
So your code becomes:
========
use Tcl::Tk qw/:perlTk/;

use warnings;
use strict;
my ($mw,$pane_fr);
$mw = MainWindow->new();
$mw->geometry("300x100");

$mw->Declare('Pane','ScrollableFrame',-require=>'BWidget');

$pane_fr = $mw->Scrolled('Pane',-scrollbars=>'osoe')->pack(-fill=>'both',
                                -expand=>1,
                               );
MainLoop;
===========

However, if actual usage of Tk::Pane is different, a bit more coding is
required to support Tk::Pane better (however that code is quite quick to do)

We can add support of Tk::Pane widget directly to Tcl::Tk, if that sounds
reasonable.

Also, it is currently a limitation that 'Scrolled' now always overrides
-scrollbars option with 'osoe'; let us know if this is a problem.

Vadim.

Reply via email to