Discussion:
Limitation of Notebook
(too old to reply)
Sumit Nagpal
2003-12-12 05:38:19 UTC
Permalink
Hi,


As we all know that the Notebook widget doesnt wrap the tabs to next
line when the number of tabs are more than what size of the containing
widget can accomodate.

Is there any solution/patch for this ?

I know one workaround ie to make notebook inside pages of another
notebook widget.But this wont do for me.

Please suggest.

Thanks
Sumit Nagpal
Slaven Rezic
2003-12-13 08:47:10 UTC
Permalink
Post by Sumit Nagpal
Hi,
As we all know that the Notebook widget doesnt wrap the tabs to next
line when the number of tabs are more than what size of the containing
widget can accomodate.
Is there any solution/patch for this ?
I don't think so.
Post by Sumit Nagpal
I know one workaround ie to make notebook inside pages of another
notebook widget.But this wont do for me.
Some consider multiple rows in notebooks as bad GUI design. See
http://www.umlchina.com/GUI/Tab.htm

Regards,
Slaven
--
Slaven Rezic - ***@rezic.de

tknotes - A knotes clone, written in Perl/Tk.
http://ptktools.sourceforge.net/#tknotes
Dean Arnold
2003-12-13 19:23:23 UTC
Permalink
Post by Slaven Rezic
Post by Sumit Nagpal
Hi,
As we all know that the Notebook widget doesnt wrap the tabs to next
line when the number of tabs are more than what size of the containing
widget can accomodate.
Is there any solution/patch for this ?
I don't think so.
Post by Sumit Nagpal
I know one workaround ie to make notebook inside pages of another
notebook widget.But this wont do for me.
Some consider multiple rows in notebooks as bad GUI design. See
http://www.umlchina.com/GUI/Tab.htm
Regards,
Slaven
--
tknotes - A knotes clone, written in Perl/Tk.
http://ptktools.sourceforge.net/#tknotes
Thanks for the link.
Is there a prefered alternative to the notebook ?
I'm building a GUI development tool, and the notebook
seemed like a nice abstraction for providing quick access
to individual components in a project...but when there are more than
5-6 files in a project, the tabs disappear off the page,
and stacking them is a pain to manage (esp. when the
window gets resized). Is a tree display
considered a better mechanism ?

TIA,
Dean Arnold
Presicient Corp.
www.presicient.com
zentara
2003-12-14 15:59:54 UTC
Permalink
Post by Dean Arnold
I'm building a GUI development tool, and the notebook
seemed like a nice abstraction for providing quick access
to individual components in a project...but when there are more than
5-6 files in a project, the tabs disappear off the page,
and stacking them is a pain to manage (esp. when the
window gets resized). Is a tree display
considered a better mechanism ?
Would a scrolled notebook work for you.
Look at this snippet.

#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::NoteBook;

our $mw = MainWindow->new;

my $canvas = $mw->Scrolled('Canvas',-bg=>'red')->pack;
our $nb = $canvas->NoteBook;

### add 20 tabs to notebook
for ( 1 .. 20 ){
my $title = "Untitled ($_)";
$nb->add( $_, -label => $title );
}

### embed the notebook widget into the canvas
my $nb_in_canvas = $canvas->createWindow( 0, 0, -window => $nb,
-anchor => 'nw' );
$canvas->update;
### the whole notebook is larger than what can be initially displayed
### so we'll have to sroll it later on in the program

$canvas->configure( -scrollregion => [0,0,$nb->reqwidth,$nb->reqheight]
);

MainLoop;
__END__


--
When life conspires against you, and no longer floats your boat,
Don't waste your time with crying, just get on your back and float.
Dean Arnold
2003-12-14 17:57:59 UTC
Permalink
Post by zentara
Post by Dean Arnold
I'm building a GUI development tool, and the notebook
seemed like a nice abstraction for providing quick access
to individual components in a project...but when there are more than
5-6 files in a project, the tabs disappear off the page,
and stacking them is a pain to manage (esp. when the
window gets resized). Is a tree display
considered a better mechanism ?
Would a scrolled notebook work for you.
Look at this snippet.
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::NoteBook;
our $mw = MainWindow->new;
my $canvas = $mw->Scrolled('Canvas',-bg=>'red')->pack;
our $nb = $canvas->NoteBook;
### add 20 tabs to notebook
for ( 1 .. 20 ){
my $title = "Untitled ($_)";
$nb->add( $_, -label => $title );
}
### embed the notebook widget into the canvas
my $nb_in_canvas = $canvas->createWindow( 0, 0, -window => $nb,
-anchor => 'nw' );
$canvas->update;
### the whole notebook is larger than what can be initially displayed
### so we'll have to sroll it later on in the program
$canvas->configure( -scrollregion => [0,0,$nb->reqwidth,$nb->reqheight]
);
MainLoop;
__END__
Ahh, just what I was looking for....however, since each notebook
page I'll be displaying is a Scrolled Tk:Text
widget, the extra scrollbars may be a bit confusing...
but I'll play with this...

Many thanks,
Dean Arnold
Presicient Corp.
www.presicient.com
zentara
2003-12-15 15:39:08 UTC
Permalink
Post by Dean Arnold
Post by zentara
Would a scrolled notebook work for you.
Look at this snippet.
Ahh, just what I was looking for....however, since each notebook
page I'll be displaying is a Scrolled Tk:Text
widget, the extra scrollbars may be a bit confusing...
but I'll play with this...
I tried playing around for self-education, and came up with this.
It uses the Tk:Pane.
There is just one problem I can't seem to figure out.
When you click on Tab 20(at the far right), the textbox is off
screen to the left. I need to find a way to make the tab
focus on itself, or automatically scroll to the left. It's not
much of a problem for only a few items, but it certainly shows up
when you approach 40 tabs.

#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::NoteBook;
use Tk::Pane;

my $mw = MainWindow->new();
$mw->geometry('600x400+300+100');

my $pane = $mw->Scrolled('Pane', Name => 'scroll test',
-width => 600,
-height => 400,
-scrollbars => 'osoe',
-sticky => 'nw',
);
$pane->pack;

my $nb = $pane->NoteBook(-width=>400,
-background => 'green',
);

my @colors = qw(ivory yellow white black cyan pink snow
linen bisque green azure gray
navy blue turquoise chartreuse khaki
gold peru red);

my %tabs;

for(1..20){
$tabs{$_}{'name'} = 'tab'.$_;
#print 'tab->',$tabs{$_}{'name'},"\n";
my $tab = $nb->add("page$_", -label=>"Student $_");

$tabs{$_}{'text'} = $tab->Scrolled('Text', -scrollbars=>'se',
,-bg => $colors[0])
->pack(-side => 'left',
-anchor => 'n');
$tabs{$_}{'text'}->insert('end', "Tab $_");

$tabs{$_}{'canvas'} = $tab->Canvas(-background=>"yellow")
->pack(-side => 'left',
-anchor => 'n');

$tabs{$_}{'canvas'}->createText(30,40, -text=>"Canvas $_");

#$nb->Resize;
push (@colors,shift(@colors));
}

$nb->pack(qw/-side top/);

$tabs{1}{'text'}->insert('end',"\nAdd this from outside the loop");

MainLoop;
__END__



--
When life conspires against you, and no longer floats your boat,
Don't waste your time with crying, just get on your back and float.
Slaven Rezic
2003-12-14 23:09:14 UTC
Permalink
Post by Dean Arnold
Post by Slaven Rezic
Post by Sumit Nagpal
Hi,
As we all know that the Notebook widget doesnt wrap the tabs to next
line when the number of tabs are more than what size of the containing
widget can accomodate.
Is there any solution/patch for this ?
I don't think so.
Post by Sumit Nagpal
I know one workaround ie to make notebook inside pages of another
notebook widget.But this wont do for me.
Some consider multiple rows in notebooks as bad GUI design. See
http://www.umlchina.com/GUI/Tab.htm
Regards,
Slaven
--
tknotes - A knotes clone, written in Perl/Tk.
http://ptktools.sourceforge.net/#tknotes
Thanks for the link.
Is there a prefered alternative to the notebook ?
I'm building a GUI development tool, and the notebook
seemed like a nice abstraction for providing quick access
to individual components in a project...but when there are more than
5-6 files in a project, the tabs disappear off the page,
and stacking them is a pain to manage (esp. when the
window gets resized). Is a tree display
considered a better mechanism ?
Look at the configuration dialogs of KDE programs. On the left side
there's a scrolled listbox with all section, and the frame contents
appear on the right side.

(Note to myself: I should probably add an option to Tk::Getopt to look
just like this)

Regards,
Slaven
--
Slaven Rezic - ***@rezic.de

sf-upload: make batch releases on SourceForge
http://sf-upload.sf.net
Loading...