Acme-Gtk2-Ex-Builder

 view release on metacpan or  search on metacpan

README.mkdn  view on Meta::CPAN

# NAME

Acme::Gtk2::Ex::Builder - Funny Gtk2 Interface Design Module

# VERSION

version 0.008

# SYNOPSIS

    use strict;
    use warnings;
    use Gtk2 -init;
    use Acme::Gtk2::Ex::Builder;
    

    my $app = build {
        widget Window => contain {
            info id           => 'window';
            set  title        => 'Awesome App';
            set  default_size => 200, 100;
            set  position     => 'center';
            on   delete_event => sub { Gtk2->main_quit; };
    

            widget Button => contain {
                set label  => 'Action';
                on clicked => sub { say 'Seoul Perl Mongers!' };
            };
        };
    };
    

    $app->find('window')->show_all;
    Gtk2->main;

# METHODS

## find

Find and get widget by ID.
You can find widget only you set `id` with `info` function.

    my $app = build {
        widget Window => contain {
            info id => 'my-window';
        };
    };
    

    my $window = $app->find('my-window');

# FUNCTIONS

## build

This function acts like ordinary "new" method.
It is exported by default and returns [Acme::Gtk2::Ex::Builder](http://search.cpan.org/perldoc?Acme::Gtk2::Ex::Builder) object.
It can contains several `widget` functions.

    my $app = build {
        widget Window;
        widget Dialog;
        widget FileChooser;
        widget VBox;
    };

## widget

This function creates the Gtk2 widget.
In fact when you use this, `Gtk2::XXX->new` will be called.
See [Gtk2](http://search.cpan.org/perldoc?Gtk2) and Gtk2 API reference.

Following code will call `Gtk2::Window->new`.

    my $app = build {
        widget Window;
    };

If you need more children widgets,
use `contain`, then call `widget` again and again.

    my $app = build {
        widget Window contain => {
            widget HBox => contain {
                widget Button;
                widget Button;
                widget Button;



( run in 0.637 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )