Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Tk geometry scrolled frame

by Takamoto (Monk)
on Mar 29, 2019 at 22:36 UTC ( [id://1231884]=perlquestion: print w/replies, xml ) Need Help??

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

Hello

I have a quite stupid problem with the geometry in Tk. How can I make the content of the second tab 'right' to be left aligned as in tab 'left'? Thanks.

use strict; use warnings; use Tk; use Tk::Notebook; use Tk::Pane; my (@packWidgetTopTitel) = qw/-side top -anchor w -pady 1m/; my (@packWidgetTop) = qw/-side top -anchor w/; my $CkAtSearchUserDatabase; my $CkMergedWindow; my $mw = MainWindow->new(); my $book = $mw->NoteBook(-relief => 'flat')->pack(-side => 'top' , -ex +pand => '1', -fill => "both", -ipadx => 6, -ipady => 6); my $page1 = $book->add( "Sheet1", -label=>'left'); my $page2 = $book->add( "Sheet2", -label=>'right'); #left $page1->Label(-text => "OFF-LINE RESOURCES")->pack(@packWidgetTopT +itel); $page1 -> Checkbutton(-text=>"My old data", -variable=>\$CkAtS +earchUserDatabase)->pack(@packWidgetTop); #right my $PaneT = $page2->Scrolled('Frame', -scrollbars => 'oe', )->pack(-expand => '1', -fill => 'both', -anchor=> 'w'); $PaneT->Label(-text=>"ON-LINE RESOURCES")->pack(@packWidgetTop +Titel); $PaneT -> Checkbutton(-text=>"YXX", -variable=>\$CkMergedWindo +w1)->pack(@packWidgetTop); $PaneT -> Checkbutton(-text=>"XYX", -variable=>\$CkMergedWindo +w2)->pack(@packWidgetTop); $PaneT -> Checkbutton(-text=>"XXY", -variable=>\$CkMergedWindo +3)->pack(@packWidgetTop); MainLoop;

Replies are listed 'Best First'.
Re: Tk geometry scrolled frame
by Athanasius (Archbishop) on Mar 30, 2019 at 04:40 UTC

    Hello Takamoto,

    I made 3 changes to the code shown:

    (1) Changed use Tk::Notebook; to use Tk::NoteBook; (note the uppercase letter B).

    (2) Added:

    my $CkMergedWindow1; my $CkMergedWindow2; my $CkMergedWindo3;

    to get the code to compile, as per tybalt89’s observation above.

    (3) Changed this line:

    my $PaneT = $page2->Scrolled('Frame',

    to this:

    my $PaneT = $page2->Scrolled('NoteBook',

    The resulting “right” tab now appears left-aligned, as desired. However, despite the call to Scrolled, there are still no scroll bars. :-(

    Hope that helps (a little),

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Re: Tk gemoetry scrolled frame
by Takamoto (Monk) on Mar 30, 2019 at 10:13 UTC

    After playing around a little bit, I came out with a solution. Here is the final code.

    use strict; use warnings; use Tk; use Tk::NoteBook; use Tk::Pane; my (@packWidgetTopTitel) = qw/-side top -anchor w -pady 1m/; my (@packWidgetTop) = qw/-side top -anchor w/; my $CkAtSearchUserDatabase; my $CkMergedWindow1; my $CkMergedWindow2; my $CkMergedWindow3; my $mw = MainWindow->new(); my $book = $mw->NoteBook(-relief => 'flat')->pack(-side => 'top' , -ex +pand => '1', -fill => "both", -ipadx => 6, -ipady => 6); my $page1 = $book->add( "Sheet1", -label=>'left'); my $page2 = $book->add( "Sheet2", -label=>'right'); #left $page1->Label(-text => "OFF-LINE RESOURCES")->pack(@packWidgetTopT +itel); $page1 -> Checkbutton(-text=>"My old data", -variable=>\$CkAtS +earchUserDatabase)->pack(@packWidgetTop); #right my $PaneT = $page2->Scrolled('Pane', -scrollbars => 'oe', )->pack(-anchor=> 'w'); $PaneT->Label(-text=>"ON-LINE RESOURCES")->pack(@packWidgetTop +Titel); $PaneT -> Checkbutton(-text=>"YXX", -variable=>\$CkMergedWindo +w1)->pack(@packWidgetTop); $PaneT -> Checkbutton(-text=>"XYX", -variable=>\$CkMergedWindo +w2)->pack(@packWidgetTop); $PaneT -> Checkbutton(-text=>"XXY", -variable=>\$CkMergedWindo +w3)->pack(@packWidgetTop); MainLoop;

    Thank you for the help.

      No, actually it doesn't work. The Pane/Frame doesn't occupy the whole space, which can be seen reducing the height of the widget until the Scroll- bar is displayed. A bit puzzled...

        Try this

        #!/usr/bin/perl # https://perlmonks.org/?node_id=1231884 use strict; use warnings; use Tk; use Tk::NoteBook; use Tk::Pane; my (@packWidgetTopTitel) = qw/-side top -anchor w -pady 1m/; my (@packWidgetTop) = qw/-side top -anchor w/; my $CkAtSearchUserDatabase; my $CkMergedWindow1; my $CkMergedWindow2; my $CkMergedWindow3; my $mw = MainWindow->new(); my $book = $mw->NoteBook(-relief => 'flat')->pack(-side => 'top' , -ex +pand => '1', -fill => "both", -ipadx => 6, -ipady => 6); my $page1 = $book->add( "Sheet1", -label=>'left'); my $page2 = $book->add( "Sheet2", -label=>'right'); #left $page1->Label(-text => "OFF-LINE RESOURCES")->pack(@packWidgetTopTit +el); $page1 -> Checkbutton(-text=>"My old data", -variable=>\$CkAtSearc +hUserDatabase)->pack(@packWidgetTop); #right my $PaneT = $page2->Scrolled('Pane', -scrollbars => 'osoe', -sticky => 'nsew', )->pack(-anchor=> 'w', -fill => 'x'); $PaneT->Label(-text=>"ON-LINE RESOURCES")->pack(@packWidgetTopTite +l); $PaneT -> Checkbutton(-text=>"YXX", -variable=>\$CkMergedWindow1)- +>pack(@packWidgetTop); $PaneT -> Checkbutton(-text=>"XYX", -variable=>\$CkMergedWindow2)- +>pack(@packWidgetTop); $PaneT -> Checkbutton(-text=>"XXY", -variable=>\$CkMergedWindow3)- +>pack(@packWidgetTop); MainLoop;
Re: Tk gemoetry scrolled frame
by tybalt89 (Monsignor) on Mar 29, 2019 at 23:26 UTC

    Does not compile

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-24 03:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found