Re: How to install a signal handler to an pixmap?



To all about [ How to install a signal handler to an pixmap? ]:
+--->
| Hi,
| I've got another problem where can't help myself....
| How do I connect a signal handler to an pixmap in a table ???
| I've written the following:
| $keinbutton[$kein]->set_events( [ $keinbutton[$kein]->get_events(), 
| 'button-press-mask'] );
| $keinbutton[$kein]->signal_connect("button_press_event", sub { print "Drückte 
| $y\n" }, $y);
| Where $keinbutton[$kein] is a pixmap and $y is an integer  which I later want 
| to give to the routine which is called by this event when it works.
| My code won't compile because I think $keinbutton[$kein]->get_events() isn't 
| valid so it gives an undefined value back. I would need it for a game.... So 
| how can I connect the signal handler correct so that I don't have to give up 
| my table or something....
| Thx,
| kx
| PS: I am sorry for being such a newbie to Gtk-perl, I only made non-graphic 
| progs before.
| gtk-perl-list mailing list
| gtk-perl-list gnome org
| http://mail.gnome.org/mailman/listinfo/gtk-perl-list
+--->


So, I answer on it:

   Hello, David! :)
Maybe you need to connect handler to button with pixmap? 
Ok, do this:

-------------------------8<-------------------------
# Here is should be an pixmap array, or you can access pixmap from
# file, but I like this way

@exit_small_xpm = ('24 24 20 1',
'       c None',
'.      c #2F2820',
'+   c #115374',
'@   c #0291DC',

[XPM ARRAY HERE]

'        %.] ;&^^^^^^^!> ',
'        ])   ]###.#..>; ');



# Ok. Now we construct some button-maker with image

sub xpm_label_box
{
   ( $parent, $xpm, $label_text ) = @_;
 
   $box;
   $style;
   $pixmap;
   $mask;
   $pixmapwid;
   $label;
 
   $box = new Gtk::HBox( 0, 0 );
   $style = $parent->get_style()->bg( 'normal' );
   ($pixmap, $mask) = Gtk::Gdk::Pixmap->create_from_xpm_d($parent->window,$style,@$xpm);
   $pixmapwid = new Gtk::Pixmap( $pixmap, $mask );
   $label = new Gtk::Label( $label_text );
   $box->pack_start( $pixmapwid, 0, 0, 3 );
   $box->pack_start( $label, 0, 0, 3 );
   $box->border_width( 2 );
   $pixmapwid->show();
   $label->show();
   return ( $box );
}    


# No comment ;o) 
sub ku_ku {
   print "Ku-ku! It works or not?\n";
}

# Construct you real button...
    $your_button = &xpm_label_box( $your_window, \ edit_small_xpm, "Label" );

    ...

# ...and access an handler
    $your_button->signal_connect('clicked', \&ku_ku);
-------------------------8<-------------------------

Hmmm.... Approximately like this. ;o)
--
./bo

[ Fri Apr  6 09:45:55 EET 2001 ]




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