george young wrote:

[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?

You can set a gtk.Image widget to display a pixmap (like the gtk.Pixmap widget can) using its "set_from_pixmap" method, which acts like the gtk.Pixmap.set() method. That may make it a bit easier to convert your code.

James.

--
Email: [EMAIL PROTECTED] | Linux.conf.au http://linux.conf.au/
WWW: http://www.daa.com.au/~james/ | Jan 22-25 Perth, Western Australia.


_______________________________________________
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