$loglbl->configure(-scrollcommand => [$s, 'set']);
Do you want to scroll the label ($loglbl) or the frame ($logfrm)?
(Hint: -scrollcommand is not a valid option for labels; it is for frames.)
BTW, nice first post - you obviously took the time to learn some Monastery HTML coding for a readable post. You also stated the problem fairly succinctly with example code and the error received. ++
| [reply] [Watch: Dir/Any] [d/l] [select] |
I'm not sure. It's the first time I create a GUI. Anyway, my frame ($logfrm) has a fixed dimension and a border. The content of the label ($loglbl) increases when the program runs. The label grows too much, but I want to keep the frame's initial dimensions. So I would like to be able to "navigate" the content of the $loglbl.
I suppose I should scroll the label($loglbl)?
P.S.: Thanks for your comment. It's true; I took a look to the "Monastry HTML". And I apologize for my english level...I sudied it only a couple of years, but I find it much harder then the Perl language! :D
| [reply] [Watch: Dir/Any] |
Think of it like this:
- the frame has fixed dimension
- the label content is more than can been seen in the fixed frame
- therefore the label is bigger than the frame
- therefore the frame needs to scroll to show all the label
| [reply] [Watch: Dir/Any] |
I don't use Tkx, but if it is similar to plain Tk, it is almost always better to use the Scrolled widget, i.e. the Scrolled Pane instead of trying to scroll Frames. Frames are just too dumb, code and signal wise. This ought to be easy enough to convert to Tkx.... it shows how to nest scrolled panes.
#!/usr/bin/perl
use strict;
use Tk;
use Tk::Pane;
my $mw = MainWindow->new;
$mw->geometry('400x250');
my $mwf = $mw->Scrolled('Pane',
-scrollbars=>'osoe',
-sticky=>'nwse',
)->pack(-expand=>1, -fill=>'both');
my $f1 = $mwf->Frame()->pack();
my $f2 = $mwf->Frame()->pack();
my %canv;
for (0..4){
$canv{$_}{'obj'} = $f1->Scrolled('Canvas',
-height => 100,
-width => 100,
-bg =>'white',
-scrollbars => 'osoe',
-scrollregion => [ 0, 0, 500, 500 ],
)->pack(-side =>'left' ,-padx=>10,-pady=>10);
$canv{$_}{'obj'}->createText(50,50,
-text => $_,
-anchor => 'center',
);
}
for (5..9){
$canv{$_}{'obj'} = $f2->Scrolled('Canvas',
-height => 100,
-width => 100,
-bg =>'white',
-scrollbars => 'osoe',
-scrollregion => [ 0, 0, 500, 500 ],
)->pack(-side =>'left', -padx=>10,-pady=>10 );
$canv{$_}{'obj'}->createText(50,50,
-text => $_,
-anchor => 'center',
);
}
MainLoop();
| [reply] [Watch: Dir/Any] [d/l] |
#=begin
my $s = $logfrm->new_ttk__scrollbar(-orient => 'vertical', -comman
+d => [$loglbl, 'yview']);
$loglbl->configure(-scrollcommand => [$s, 'set']);
... it looks like you're trying to create a scrollbar from your Frame widget, but then you call configure on your Label widget, which is probably not what you want to do.
However, I don't think fixing that resolves your problems. Looking through the docs for the Frame widget, there's no --scrollcommand option. The Frame widgets, frustratingly, cannot have scrollbars added to them. I tried for a while to figure out a way to make it happen the last time I used Tkx, but ended up redesigning my GUI so I didn't need a scrollable Frame.
-- baldmantom | [reply] [Watch: Dir/Any] [d/l] [select] |