Re: [pygtk] How to draw images inside GnomeCanvas polygons?
On Fri, 4 Aug 2000, Ben Escoto wrote: I would like to fill a GnomeCanvasItem on the GnomeCanvas with an xpm. How is this done? The Gnome User Interface API documentation says that, for instance, GnomeCanvasEllipse takes a GdkWindow object as the fill_stipple argument, and description.py in the pygtk distribution says that GdkWindow = GdkPixmap. Does does that mean I can create a pixmap and pass it as fill_stipple=pixmap to GnomeCanvasEllipse? A stipple is a bitmap, so unless the image is only two colours, I don't think this would work. I am not sure if there is a way to do what you want with the standard canvas items. Here is a bit of code that doesn't work (no errors, just doesn't look like anything): [snip] Why is pix a tuple? If I say pix[0] instead of pix[1] I get an error the function returns a pixmap and the mask. The mask is used to draw shaped pixmaps (the pixmap is only painted where the mask is set to 1). I don't understand: Gdk-ERROR **: BadMatch (invalid parameter attributes) serial 209 error_code 8 request_code 56 minor_code 0 The stipple can only be a bitmap. The pixmap would have been created in the default visual, which is probably not two colours. The mask is a bitmap however. If I substitute fill_color="black" in for fill_stipple I get the intended circle. I would appreciate anyone pointing me in the right direction. It has taken me hours to figure out this much, and I don't know of any examples of what I am trying to do (at least none are included in the pygtk or pygnome distributions. -- Ben Escoto James. -- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] How to draw images inside GnomeCanvas polygons?
"JH" == James Henstridge [EMAIL PROTECTED] wrote the following on Sat, 5 Aug 2000 17:04:23 +0800 (WST) I would like to fill a GnomeCanvasItem on the GnomeCanvas with an xpm. How is this done? JH A stipple is a bitmap, so unless the image is only two colours, JH I don't think this would work. I am not sure if there is a way JH to do what you want with the standard canvas items. Thanks for your response, I appreciate it. Then is the best way to do it to forget about the GnomeCanvas and just use gdk commands? For instance, could I make a bitmap of a polygon, and then use that to screen off an image, and the result would have the same effect as sticking a pixmap in a polygon? I just don't want to waste time trying to do something in a way that can't be done or in an obviously stupid way. For instance, I orginally wrote my program (a spherical pager, see http://www.stanford.edu/~bescoto/tmp/sphere-pager.jpg for current screenshot) using Tkinter, but then switched it to Gtk because I was under the impression that GnomeCanvas had (working) anti-aliased graphics and polygons I could stick pictures in... -- Ben Escoto ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
Re: [pygtk] How to draw images inside GnomeCanvas polygons?
On Sat, 5 Aug 2000, Ben Escoto wrote: "JH" == James Henstridge [EMAIL PROTECTED] wrote the following on Sat, 5 Aug 2000 17:04:23 +0800 (WST) I would like to fill a GnomeCanvasItem on the GnomeCanvas with an xpm. How is this done? JH A stipple is a bitmap, so unless the image is only two colours, JH I don't think this would work. I am not sure if there is a way JH to do what you want with the standard canvas items. Thanks for your response, I appreciate it. Then is the best way to do it to forget about the GnomeCanvas and just use gdk commands? For instance, could I make a bitmap of a polygon, and then use that to screen off an image, and the result would have the same effect as sticking a pixmap in a polygon? I just don't want to waste time trying to do something in a way that can't be done or in an obviously stupid way. That is basically correct. You want to create a 1-bit depth pixmap (bitmap) as a mask, and draw the polygon on that. Then set it as a clip mask for the GC and then draw the pixmap with it. This will clip the pixmap. For instance, I orginally wrote my program (a spherical pager, see http://www.stanford.edu/~bescoto/tmp/sphere-pager.jpg for current screenshot) using Tkinter, but then switched it to Gtk because I was under the impression that GnomeCanvas had (working) anti-aliased graphics and polygons I could stick pictures in... -- Ben Escoto James. -- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/ ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk
[pygtk] How to draw images inside GnomeCanvas polygons?
I would like to fill a GnomeCanvasItem on the GnomeCanvas with an xpm. How is this done? The Gnome User Interface API documentation says that, for instance, GnomeCanvasEllipse takes a GdkWindow object as the fill_stipple argument, and description.py in the pygtk distribution says that GdkWindow = GdkPixmap. Does does that mean I can create a pixmap and pass it as fill_stipple=pixmap to GnomeCanvasEllipse? Here is a bit of code that doesn't work (no errors, just doesn't look like anything): from gtk import * from gnome.ui import * window = GtkWindow(WINDOW_TOPLEVEL) window.set_usize=(100.0, 100.0) canvas = GnomeCanvas() canvas.set_usize=(100.0, 100.0) canvas.set_scroll_region(0.0,0.0, 100.0,100.0) window.add(canvas) pix = create_pixmap_from_xpm(canvas, None, "test.xpm") e = canvas.root().add('ellipse') e.set(x1=0.0, y1=0.0, x2=90.0, y2=90.0, fill_stipple=pix[1]) canvas.show() window.show() mainloop() Why is pix a tuple? If I say pix[0] instead of pix[1] I get an error I don't understand: Gdk-ERROR **: BadMatch (invalid parameter attributes) serial 209 error_code 8 request_code 56 minor_code 0 If I substitute fill_color="black" in for fill_stipple I get the intended circle. I would appreciate anyone pointing me in the right direction. It has taken me hours to figure out this much, and I don't know of any examples of what I am trying to do (at least none are included in the pygtk or pygnome distributions. -- Ben Escoto ___ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk