Re: [pygtk] pixmap buttons?

2002-07-11 Thread Christian Reis

On Thu, Nov 01, 2001 at 09:22:10AM -0600, Skip Montanaro wrote:
> 
> 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.

I've added an example that is for gtk1 (but should work in gtk2) to the
faq:

http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq09.002.htp

Note that the example shows how you can add both a label and a pixmap. A
simple pixmap button avoids the need for a GtkH/VBox.

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



Re: [pygtk] pixmap buttons?

2001-11-01 Thread Skip Montanaro


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