Re: gtk-perl-list Digest, Vol 16, Issue 2



On Tue,  2 Aug 2005 09:06:04 -0400 (EDT)
gtk-perl-list-request gnome org wrote:

Date: Tue, 02 Aug 2005 20:05:29 +0700
From: Beast <beast i6x org>
Subject: Button with image

1. Is it possible to create new button with image without adding in 
Gtk2::Stock?

2. I can not found gtk_stock_add documentation in gtk+ site, however it 
was there in gtk-perl site, is Gtk2::Stock only available in gtk-perl?
--beast

Here is an example I have, I didn't write it, found it in a tutorial somewhere
or from the net.

#!/usr/bin/perl
use warnings;
use strict;
######################################################################
# An example illustrating images and markup.
######################################################################
use Gtk2 '-init';

my $window = Gtk2::Window->new;
my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file("bridget-1.jpg");
my $image  = Gtk2::Image->new_from_pixbuf($pixbuf);
my $button = Gtk2::Button->new();
my $vbox   = Gtk2::VBox->new();
my $label  = Gtk2::Label->new("Press this button!");
$vbox->pack_start( $label, 0, 0, 0 );
$vbox->pack_start( $image, 0, 0, 0 );
$window->set( border_width => 15 );
$button->add($vbox);    # <- You can pack any widget inside a button!
$window->add($button);

$button->signal_connect(
    clicked => sub {
        $label->set_markup(
            "<b>Thank " . "<span foreground=\"blue\">" . "you</span>!</b>" );
    }
);

$window->signal_connect('destroy', sub { Gtk2->main_quit });

$window->show_all();
Gtk2->main;


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]