Edit : Never mind, I solve this with a $window->show_all; inside the callback sub.

hi, I am developping a Gtk3 application that uses a notebook (widget with tabs). I can't add a new page to the notebook (append_page) when calling from a signal callback sub (click on a button)

use strict; use warnings; use Glib 'TRUE', 'FALSE'; use Gtk3 -init; #new window and box my $window = Gtk3::Window->new ('toplevel'); my $box = Gtk3::Box->new( 'vertical', 0); my $notebook = Gtk3::Notebook->new(); # ----> works : append a new page in the notebook my $n = Gtk3::Label->new('TABNAME'); my $c = Gtk3::Label->new('TABCONTENT'); $notebook->append_page ($c, $n); my $btn = Gtk3::Button->new('Add page'); $btn->signal_connect('clicked' => sub { # ----> same code does nothing when called from a signal callback +sub my $n = Gtk3::Label->new('TABNAME'); my $c = Gtk3::Label->new('TABCONTENT'); $notebook->append_page ($c, $n); }); #add and show widgets $box->pack_start($notebook, TRUE, TRUE, 0); $box->add($btn); $box->set_size_request (500, 300); $window->add($box); $window->show_all; Gtk3::main;

the example code I've found never add a new tab from a callback but from hard coding this is gtk2 but whatever Any pointers is appreciated.

s

In reply to Gtk3 notebook, append a page from a signal by neoldschool

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.