Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Gtk2::Notebook with large tabs

by thanos1983 (Parson)
on May 27, 2015 at 23:57 UTC ( [id://1128084]=note: print w/replies, xml ) Need Help??


in reply to Gtk2::Notebook with large tabs

Hello Anonymous Monk,

Since I am not familiar with Gtk2 I can not really help you. But I did not searched online and I came up with $notebook->set_tab_border ($border_width) I think this is probably what you are looking for. You can find other adjustments that you might be interested Gtk2::Notebook.

Also if you have some time I would suggest to read also the new Perl module Gtk3s it has some extra features that you might be interested.

Give it a try and reply to your question if you get more information(s) / solution(s), so other can benefit from.

Any way as I said I have never used the module before so I hope my answer helped you or at least pointed you to the correct direction.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: Gtk2::Notebook with large tabs
by Anonymous Monk on May 28, 2015 at 09:07 UTC

    Hey thanos1983, thanks for your suggestion!

    It suddenly occured to me, while fiddling with ->set_tab_border(), that it might be the stock icon that was preventing the label from becoming smaller.

    Sure enough, removing the stock icon altogether reduces the tab's size dramatically. Using a smaller stock icon is also effective:

    $noteBook->set_tab_border(0); $button->set_image(Gtk2::Image->new_from_stock('gtk-close', 'menu'));
    Here's the corrected script:
    #!/usr/bin/perl package biglabel; use strict; use diagnostics; use warnings; use Gtk2 '-init'; use Glib qw(TRUE FALSE); # Create the window my $window = Gtk2::Window->new(); $window->set_title('Notebook'); $window->set_position('center'); $window->set_default_size(800, 500); $window->set_border_width(5); $window->signal_connect (destroy => sub { Gtk2->main_quit; }); # Add a VBox with a VPaned, containing a notebook at the top and an en +try at the bottom my $vBox = Gtk2::VBox->new(FALSE, 0); my $vPaned = Gtk2::VPaned->new(); $vPaned->set_position(400); $vBox->pack_start($vPaned, TRUE, TRUE, 0); my $noteBook = Gtk2::Notebook->new(); $noteBook->set_scrollable(TRUE); $noteBook->can_focus(FALSE); $noteBook->set_tab_border(0); $vPaned->add($noteBook); my $entry = Gtk2::Entry->new(); $entry->can_focus(TRUE); $vPaned->add2($entry); # Add three tabs to the notebook for (my $num = 0; $num < 3; $num++) { my ($buffer, $tabNum) = openTab($noteBook); } # Open the window $window->add($vBox); $window->show_all(); Gtk2->main(); #################### sub openTab { # Create a tab in the notebook, containing a textview my ($noteBook) = @_; # The vertical packing box contains only a textview my $vBox = Gtk2::VBox->new(FALSE, 0); # The horizontal packing box is used as the tab's label (in pl +ace of a Gtk2::Label) my $hBox = Gtk2::HBox->new(FALSE, 0); my $label = Gtk2::Label->new('Hello world'); $hBox->pack_start($label, FALSE, FALSE, 0); my $button = Gtk2::Button->new(); $button->set_image(Gtk2::Image->new_from_stock('gtk-close', 'm +enu')); $button->set_relief('none'); $button->signal_connect (clicked => sub { # (Do nothing special) }); $hBox->pack_start($button, FALSE, FALSE, 0); $label->show(); $button->show(); my $tabNum = $noteBook->append_page($vBox, $hBox); # Add a textview to the tab my $frame = Gtk2::Frame->new(undef); $frame->set_border_width(0); my $scroll = Gtk2::ScrolledWindow->new(undef, undef); $scroll->set_shadow_type('etched-out'); $scroll->set_policy('automatic', 'automatic'); $scroll->set_border_width(0); my $textView = Gtk2::TextView->new(); my $buffer = Gtk2::TextBuffer->new(); $textView->set_buffer($buffer); $textView->set_editable(FALSE); $textView->set_cursor_visible(FALSE); # Invisible cursor $textView->can_focus(FALSE); $textView->set_wrap_mode('word-char'); # Wrap words if possib +le, characters if not $textView->set_justification('left'); $scroll->add($textView); $frame->add($scroll); $vBox->pack_start($frame, TRUE, TRUE, 0); $window->show_all(); # The new tab should be the visible (current) one $noteBook->set_current_page($tabNum); return ($buffer, $tabNum); }

      Hello Anonymous,

      I am glad that you got the answer to your question that you where looking for even through alternative solution. A different point of view is always good. Just keep on trying failing and happy coding... :D .

      Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?
Username:
Password:

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

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

    No recent polls found