[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: button children!!
- From: Andy Ford <andy ford telindus co uk>
- To: muppet <scott asofyet org>
- Cc: gtk-perl-list gnome org
- Subject: Re: button children!!
- Date: 28 Jan 2003 15:58:51 +0000
Thanks muppet - that is in fact what I did in the end - I became
extremely bored of looking for the correct method!!!
Maybe you could answer this next one for me ....
I am trying to swap a pixmap with a new one every time a button is
clicked. Is this possible or will I need to use gtkImage??
I have the correct methods for 'clicked' etc and pass the pixmap widget
and label widget I had on the button to the function call.
i.e. $button->signal_connect( "clicked", \&func, \$pixmapwid,
\$label_wid );
What I am trying to do now is replace the pixmap displayed on the
pixmap_wid
Thanks
On Tue, 2003-01-28 at 14:16, muppet wrote:
> On Tue, 2003-01-28 at 05:39, Andy Ford wrote:
> > If I do a $button_hbox->children();
> > and print out the result, I get a value of '2' !!!!
> >
> > Any suggestions as to which method I could use to do this??
>
>
> actually, i would suggest a different approach altogether.
>
> instead of trying to walk the widget hierarchy to find the label and
> pixmap you want to change, try storing pointers to them in the button
> widget itself.
>
> you can use either the object's user data or just make custom keys in
> the hash.
>
> $button = Gtk::Button->new;
> $hbox = Gtk::HBox->new;
> $pixmap = ...
> $label = ...
> $button->add ( $hbox );
> $hbox->pack_start ( $pixmap, ... );
> $hbox->pack_start ( $label, ... );
>
> # store important data pointers directly in the widget's data
> # structure so we always have access to them.
> $button->{pixmap} = $pixmap;
> $button->{label} = $label;
>
> $button->signal_connect ( clicked => sub {
> my $bn = shift;
> my $pixmap = $bn->{pixmap};
> my $label = $bn->{label};
> } );
>
>
>
>
> and even yet another approach would be to pass the values to the
> callback;
>
> $button->signal_connect ( clicked => sub {
> my $bn = shift;
> my $data = shift;
> my $label = $data->{label};
> my $pixmap = $data->{pixmap};
> }, { pixmap => $pixmap, label => $label } );
>
>
>
> --
> muppet <scott asofyet org>
--
Andy Ford
Managed Services
Telindus Ltd
Hatchwood Place
Odiham
Hants
RG29 1AB
DDI: +44 1256 709211
GSM: +44 7810 636652
-------------------------------------------
Stay in:control - http://www.thti-telindus.co.uk/incontrol/index.html
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]