Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
UPDATE1: See my first response below for solution to problem #1. Still looking for solution to problem #2.
UPDATE2: Problem #2 was resolved by replacing "Tk::NoteBook" with "Tk::DynaTabFrame", which has the required features, plus much more.

The example code below creates 3 Tk Notebook widget tabs in a Toplevel window. None of the tabs have focus, which means the contents must be clicked on before scrolling can occur. The Notebook tabs can only be navigated by clicking on the tab headers.

My questions are:

  1. How can each Notebook tab be given the focus so they are immediately scrollable without having to click on the contents?
  2. How can the Notebook tabs be navigated by using the keyboard TAB key (and Shift-TAB for reverse navigation)?

TIA for your help.

#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Menu; use Tk::More; use Tk::NoteBook; my $mw = MainWindow->new(); $mw->geometry("100x100+850+50"); $mw->iconify; my $bw = $mw->Toplevel(); $bw->geometry("850x200+500+200"); $bw->bind('<Destroy>' => sub {exit;}); $bw->bind('<Escape>' => sub {exit;}); my $book = $bw->NoteBook()->pack( -fill=>'both', -expand=>1 ); my $tab1 = $book->add( "Sheet 1", -label=>"Tab #1" ); my $more1 = $tab1->Scrolled("More", -scrollbars => "osoe" )->pack(-fil +l => "both", -expand => 1); my $menu1 = $more1->menu; $bw->configure(-menu => $menu1); $more1->Load( $0 ); my $tab2 = $book->add( "Sheet 2", -label=>"Tab #2" ); my $more2 = $tab2->Scrolled("More", -scrollbars => "osoe" )->pack(-fil +l => "both", -expand => 1); my $menu2 = $more2->menu; $bw->configure(-menu => $menu2); $more2->Load( $0 ); my $tab3 = $book->add( "Sheet 3", -label=>"Tab #3" ); my $more3 = $tab3->Scrolled("More", -scrollbars => "osoe" )->pack(-fil +l => "both", -expand => 1); my $menu3 = $more3->menu; $bw->configure(-menu => $menu3); $more3->Load( $0 ); MainLoop;

"It's not how hard you work, it's how much you get done."


In reply to Navigation and Focus - Tk Notebook Widget tabs (UPDATED) by roho

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2022-07-06 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?