Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

[Tkx] Scrolled frame problem

by sebapabst (Acolyte)
on Feb 16, 2010 at 19:59 UTC ( [id://823539]=perlquestion: print w/replies, xml ) Need Help??

sebapabst has asked for the wisdom of the Perl Monks concerning the following question:

Hi everybody. It's my first post here. I hope I'm gonna do it in the right way.

I'm working on a GUI for a pre-extistent perl program. The program is supposed to automatically adapt a .txt or XML corpus to the TEI standards. I've created tree consecutive windows. In the first two user inserts the parameters for the conversion and source folder containing the texts. The last window contains a button to start the conversion and a frame where I print the log file.

The problem is: I can't place a scrollbar on the frame containin the log. I've tried the following code :

my $logcontent; my $logfrm = $pageValidation->new_ttk__frame(-padding => "5 5 5 5"); $logfrm->g_grid(-column => 1, -row => 1, -sticky => "news"); $logfrm->configure(-borderwidth => 2, -relief => "sunken", -height => +300, -width => 605); $logfrm->g_grid_propagate(0); my $loglbl = $logfrm->new_ttk__label(-textvariable => \$logcontent, -w +raplength=>590); $loglbl->g_grid( -column => 0, -row => 0, -sticky => "new",-padx=>0, - +pady=>0, ); $loglbl->configure(-width=>98,); #=begin my $s = $logfrm->new_ttk__scrollbar(-orient => 'vertical', -command => + [$loglbl, 'yview']); $loglbl->configure(-scrollcommand => [$s, 'set']);

But i get the following error:

unknown option "-scrollcommand" at C:\Users\Seba\Desktop\Nuova cartella (2)\succ essione_3.2.0.pl line 249.

I can't find what's wrong. Many sites propose this syntax. I've found it on : http://www.tkdocs.com/tutorial/morewidgets.html

Thanks for helping

Sebastian

Replies are listed 'Best First'.
Re: [Tkx] Scrolled frame problem
by keszler (Priest) on Feb 16, 2010 at 20:16 UTC
    $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. ++

      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

        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
Re: [Tkx] Scrolled frame problem
by zentara (Archbishop) on Feb 17, 2010 at 13:38 UTC
    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();

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
Re: [Tkx] Scrolled frame problem
by BaldManTom (Friar) on Feb 18, 2010 at 01:33 UTC

    sebapabst,

    Looking at this:

    #=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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://823539]
Approved by biohisham
Front-paged by sweetblood
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-29 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found