First of all, you only need to post your question once to the list, and
please turn off HTML email when posting to a mailing list.

On Thu, 15 Mar 2001, Eduardo Soto wrote:

> Hello, this is my first program. 
> taking your examples I declared the following:
> 
> b1 = GtkButton (´Stop´)

In GTK+, a GtkButton is a container widget.  When you give an argument to
the GtkButton constructor, it creates a GtkLabel with that text and puts
it in the button.

> 
> b1.connect(´clicked´, self.stop)
> 
> I want to assign a picture called stop.gif

To put an image in the button, you first need to be able to load the image
into python, create a GtkPixmap widget, and put that in the
button.  Currently, only the GdkImlib module can load gif files for use by
pygtk, so creating the GtkPixmap widget would look something like this:
  import gtk, GdkImlib

  im = GdkImlib.Image('stop.gif')
  pix, mask = im.get_pixmap()
  pixmap = gtk.GtkPixmap(pix, mask)

You then want to create the button with the pixmap widget inside, instead
of a GtkLabel:
  button = gtk.GtkButton()
  button.add(pixmap)
  pixmap.show()  # if you use show_all() on the toplevel, this call isn't needed

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to