Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w use strict; use Gtk2 '-init'; use constant TRUE => 1; use constant FALSE => 0; my $window = Gtk2::Window->new; $window->set_title('Widget Layout'); $window->signal_connect( destroy => sub { Gtk2->main_quit; } ); $window->set_border_width(3); my $vbox = Gtk2::VBox->new( FALSE, 6 ); $window->add($vbox); my $frame = Gtk2::Frame->new('Buttons'); $vbox->pack_start( $frame, TRUE, TRUE, 0 ); $frame->set_border_width(3); my $hbox = Gtk2::HBox->new( FALSE, 6 ); $frame->add($hbox); $hbox->set_border_width(3); my $inc_button = Gtk2::Button->new('_Click Me'); $hbox->pack_start( $inc_button, FALSE, FALSE, 0 ); my $count = 1; my $add_button = Gtk2::Button->new('add_label'); $hbox->pack_start( $add_button, FALSE, FALSE, 0 ); my $rem_button = Gtk2::Button->new('remove_label'); $hbox->pack_start( $rem_button, FALSE, FALSE, 0 ); my $quit_button = Gtk2::Button->new('_Quit'); $hbox->pack_start( $quit_button, FALSE, FALSE, 0 ); $quit_button->signal_connect( clicked => sub { Gtk2->main_quit; } ); my $label = Gtk2::Label->new('Clicked 0 times.'); # has to be done after we've created the label so we can get to it $inc_button->signal_connect( clicked => sub { $label->set_text("Clicked $count times."); $count++; } ); $add_button->signal_connect( clicked => sub { $vbox->pack_start( $label, TRUE, TRUE, 0 ); $label->show } ); $rem_button->signal_connect( clicked => sub { $label->destroy; } ); $window->show_all; Gtk2->main;

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re: A dynamic Main Window in GTK2 by zentara
in thread A dynamic Main Window in GTK2 by deadpickle

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 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?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-19 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found