>Hi,
>
>I just started with pygtk and right now I am trying to create something
>like an arrow widget. In oder to get that done, I am drawing an arrow on
>a GtkPixmap which I create with gtk.create_pixmap and  draw the pixmap
>on DrawingArea.
>This works fine and I get a black arrow on a white background.
>Now I want the background to be transparent instead of white. As far as
>I can tell, I need a bitmap for that. So the first thing I tried to do
>was to create a bitmap from the pixmap, but I could not find a way to do
>this.

As you may have noticed, create_pixmap requires to know the depth of the
pixmap. If you don't specify one, it will take the depth of the current
display. In order to create a bitmap (pixmap with depth 1), you need to
create a pixmap with a depth of 1:

  bitmap = create_pixmap(None, width, height, depth)

>The next thing I tried was to create a bitmap with PIL and from that
>create a GdkBitmap with create_bitmap_from_data. This worked fine as
>well, but now I have to create the pixmap from the bitmap, because I can
>not use the bitmap in gtk.draw_pixmap() to put it on the DrawingArea. I
>also tried toconvert the bitmap I created in PIL to an rgb and than
>somehow get the xpm data to create the pixmap with
>create_pixmap_from_xpm_d, but PIL does not support xpm format in the
>tostring method. I also tried to draw rgb data from the pil image on a
>newly created pixmap by calling gtk.draw_rgb_image(), but here I only
>got a segmentation fault.
>Does anybody know of an easier way (or any way at all). Any help would
>be appreciated.
>I am using Python2.0c1, PIL 1.1 and pygtk 0.6.6.

You can copy from one pixmap to another by using the draw_pixmap command:

  draw_pixmap(destination, gc, source, xsrc, ysrc, xdest, ydest, width, height)

You can get a 'gc' for a pixmap by calling the method new_gc():

  gc = pixmap.new_gc()

>Thanks a lot

In case you are interested in a more convenient way of creating and
manipulating pixmaps and bitmaps, copying with transparency information (clipping),
or reading image files, I may help you.
I've written a class for PyGTK that handles all these things for pixmaps.
It currently uses Imlib which is only required for loading images, though.
I can mail it to you as it is not yet on my web-page (it's in an too early
state). Nevertheless, it works quite well and does a great job for my programs.

>Ralph

>P.S. Since I have not subscribed to this list yet, it would be nice if
>you could reply to this address as well

Martin Grimme - http://www.pycage.de

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to