I see three choices, Tk::DynaTabFrame, Gtk2::Notebook, and roll your own on a canvas. Here is a Gtk2 Example
#! /usr/bin/perl -w
use strict;
use Gtk2 '-init';
use Glib qw/TRUE FALSE/;
#standard window creation, placement, and signal connecting
my $window = Gtk2::Window->new('toplevel');
$window->signal_connect('delete_event' => sub { Gtk2->main_quit; });
$window->set_border_width(5);
$window->set_position('center_always');
#add and show the vbox
$window->add(&ret_vbox);
$window->show();
#our main event-loop
Gtk2->main();
sub ret_vbox {
my $vbox = Gtk2::VBox->new(FALSE,5);
#create a instance of the Gtk2::Expander class
my $expander = Gtk2::Expander->new_with_mnemonic('Expand Me');
#create the child that we want to add to it.
#----------------------------------------------
#NOTE: If we want to resize
#the widget containing the Gtk2::Expander Widget
#to the size that it was BEFORE the expansion
#we have to "add / remove" the child on each "expanded / closed" c
+ycle
#If we just add it, it will be shown and hidden, but we will not b
+e able
#to shrink the parent containing the Gtk2::Expander instance when
+hidden
#-------------------------------------------------
my $nb = &ret_notebook;
$nb->show_all;
$expander->signal_connect_after('activate' => sub {
if($expander->get_expanded){
$expander->set_label('Close Me');
$expander->add($nb);
}else{
$expander->set_label('Expand Me');
$expander->remove($nb);
$window->resize(4,4);
}
return FALSE;
});
$vbox->pack_start($expander,FALSE,FALSE,0);
$vbox->show_all();
return $vbox;
}
sub ret_notebook {
#this will create a vbox containing a Notebook
#and some widgets to manipulate the Notebook's
#properties.
my $vbox_nb = Gtk2::VBox->new(FALSE,5);
$vbox_nb->set_size_request (500, 300);
my $nb = Gtk2::Notebook->new;
#pre-set some properties
$nb->set_scrollable (TRUE);
$nb->popup_enable;
for (0..10) {
my $child = Gtk2::Frame->new("Frame of Tab $_");
#________
#The tab's label can be a widget, and does not
#need to be a label, here we create a hbox containing
#a label and close button
my $hbox = Gtk2::HBox->new(FALSE,0);
$hbox->pack_start(Gtk2::Label->new("Tab $_"),FALSE,FALSE,0);
my $btn = Gtk2::Button->new('');
$btn->set_image(Gtk2::Image->new_from_stock('gtk-close','m
+enu'));
$btn->signal_connect('clicked' => sub {
$nb->remove_page ($nb->page_num($child));
});
$hbox->pack_end($btn,FALSE,FALSE,0);
$hbox->show_all;
#________
$nb->append_page ($child,$hbox);
}
$vbox_nb->pack_start($nb,TRUE,TRUE,0);
$vbox_nb->pack_start(Gtk2::HSeparator->new(),FALSE,FALSE,5);
#call the sub that will create the table containing
#controls to manipulate the notebook
$vbox_nb->pack_end(&nb_controls($nb),FALSE,FALSE,0);
return $vbox_nb;
}
sub nb_controls {
my ($nb) = @_;
my $table = Gtk2::Table->new(3,2,TRUE);
$table->attach_defaults(Gtk2::Label->new('Tab position:'),0,1,0,1)
+;
my $cb_position = Gtk2::ComboBox->new_text;
foreach my $val (qw/left right top bottom/){
$cb_position->append_text($val);
}
$cb_position->signal_connect("changed" => sub {
$nb->set_tab_pos($cb_position->get_active_text);
});
$cb_position->set_active(2);
$table->attach_defaults($cb_position,1,2,0,1);
my $show_tabs = Gtk2::CheckButton->new("Show Tabs");
$show_tabs->set_active(TRUE);
$show_tabs->signal_connect('toggled' =>sub {
$nb->set_show_tabs($show_tabs->get_active);
});
$table->attach_defaults($show_tabs,0,1,1,2);
my $scrollable = Gtk2::CheckButton->new("Scrollable");
$scrollable->set_active(TRUE);
$scrollable->signal_connect('toggled' =>sub {
$nb->set_scrollable($scrollable->get_active);
});
$table->attach_defaults($scrollable,1,2,1,2);
my $popup = Gtk2::CheckButton->new("Popup Menu (right click on
+ tab)");
$popup->set_active(TRUE);
$popup->signal_connect('toggled' =>sub {
($popup->get_active)&&($nb->popup_enable);
($popup->get_active)||($nb->popup_disable);
});
$table->attach_defaults($popup,0,1,2,3);
return $table;
}
| [reply] [d/l] |
Thank you for that! I've never played with Gtk because I thought I remembered reading that it's sort of Unix-centric but you can get installed under Windows by jumping through multiple hoops.
On the other hand, the thought of rolling my own on a canvas and attaching an event to that never had occurred to me. I'd always seen Tk::NoteBook, and since it had tabs, just thought that would be the natural road to follow. Rather than trying to modify a module your third suggestion may be the easiest way to go.
Revolution. Today, 3 O'Clock. Meet behind the monkey bars.
If quizzes are quizzical, what are tests?
| [reply] |
Tk::DynaTabFrame didn't seem to be what I wanted needed either
In what way ? DTF certainly supports tabs on the sides. Is the text orientation the issue ? If so, I fear
you'll have challenges trying to get pTk to rotate your text (at least in a cross platform freindly way).
BTW: Tk::Notebook doesn't support tabs on the side.
Perl Contrarian & SQL fanboy
| [reply] |
Thanks! I'll have to peruse the docs a bit more. And as far as Tk::Notebook, I know it doesn't so that's why part of my original query was where I perhaps should be looking to modify a module to get side tabs.
Revolution. Today, 3 O'Clock. Meet behind the monkey bars.
If quizzes are quizzical, what are tests?
| [reply] |