Kwan> I am trying to create buttons with pixmaps (some kind of picture
    Kwan> on the button) using pygtk.

Here's a simple example (I use the 2.0 API).  Don't know how *correct* it
is, but I'm pretty sure I figured it out from someone else's example.
Obviously change the xpmfile to something on your local disk.

-- 
Skip Montanaro ([EMAIL PROTECTED])
http://www.mojam.com/
http://www.musi-cal.com/

import gtk

xpmfile = "chicago.xpm"

class XPMFileButton(gtk.Button):
    def __init__(self, xpmfile):
        gtk.Button.__init__(self)
        self.xpmfile = xpmfile
        self.eid = self.connect("expose-event", self.addxpmfile)

    def addxpmfile(self, b, evt):
        pix, mask = gtk.gdk.pixmap_create_from_xpm(self.window, None,
                                                   self.xpmfile)
        pixmap = gtk.Pixmap(pix, mask)
        self.add(pixmap)
        self.show_all()
        self.disconnect(self.eid)
        del self.eid
    
def main():
    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    window.set_title("title")
    window.connect("destroy", gtk.mainquit)

    close = XPMFileButton(xpmfile)
    close.connect("clicked", gtk.mainquit)
    window.add(close)

    window.show_all()

    gtk.mainloop()

if __name__ == "__main__":
    main()
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to