[gtk+-2.1.1, pygtk-1.99.13, python-2.2.1]
Under gtk 1.x, I had been using something like:
class Openclose(gtk.GtkToggleButton):
   ...
   minus_xpm_d = ["11 11 2 1",
        ". c #000000",
        ...
        "###########"]
   self.minus = gtk.create_pixmap_from_xpm_d(topwin.get_window(), None, 
self.minus_xpm_d)
   self.pixmap = gtk.GtkPixmap(*self.minus)
   self.add(self.pixmap)

I later switch the togglebutton's pixmap:
   def toggled_fn(self, button, win):
        if button.get_active():
            self.pixmap.set(*self.minus)
            win.show()
        else:
            self.pixmap.set(*self.plus)
            win.hide()

But under gtk2.x, it whines that I should use GtkImage instead.

I tried: 
    self.img_minus = gtk.Image()
    self.img_minus.set_from_file("minus.xpm")
    self.img = gtk.Image()
    self.img.set_from_image(*self.img_minus.get_image())

    def toggled_fn(self, button, win, img):
        if button.get_active():
            img.set_from_img(self.minus)
            win.show()
        else:
            img.set_from_img(self.plus)
            win.hide()

but set_from_img requires a second "mask" argument, which I don't
know how to produce. "Gtk.Image.get" doesn't seem to exist under
pygtk-1.99.13.  

What's the clean way to get two small (preferably inlined) images and
swap them back and forth into a togglebutton?

--
 I cannot think why the whole bed of the ocean is
 not one solid mass of oysters, so prolific they seem. Ah,
 I am wandering! Strange how the brain controls the brain!
        -- Sherlock Holmes in "The Dying Detective"
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to