Re: pixmaps

Viktor Vislobokov said:

But, there is no pixmap creation examples!

the pixmap stuff should work, but GtkImages viewing GdkPixbufs are much
easier.  this is a Gtk+ 2.x change, not merely a gtk2-perl change.

  $button = Gtk2::Button->new;
  $image = Gtk2::Image->new_from_file ($filename);
  $button->add ($image);


  $button = Gtk2::Button->new;
  eval {
    $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file ($filename);
    $image = Gtk2::Image->new_from_pixbuf ($pixbuf);
    $button->add ($image);
  if ($@) {
      warn "couldn't load $filename: $@";
      $button->set_text ("something");

and even better yet, using stock icons

  $image = Gtk2::Image->new_from_stock ('gtk-ok')


and the gtk-demo source in Gtk2/gtk-demo/*.pl

muppet <scott at asofyet dot org>

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