Sebastien Kessler wrote:
>
> I use Python 1.5.1, PyGTK and PyGNOME (I'm learning ;).
>
> 1) How can I erase (clear) the canvas without destroying it with
> canvas.destroy().
>
> That means having added several ellipses with...
>
> canvas = GnomeCanvas()
> ellipse = canvas.root().add('ellipse', x1=x1, y1=y1, x2=x2, y2=y2,
> fill_color='blue',
>
> outline_color='black',width_units=1.0)
>
> ...how can I delete *all* of them and clear the canvas (and how can
> I delete the *last one* or the
> *one just before*).
Heh. That's a good question! I just did some checking around, and I can't find
anything like gnome_canvas_item_destroy. You can of course hide them using
ellipse.hide()
You can also reparent them into a group that is hidden:
ellipse.reparent(hidden_group)
I too would like to know how to destroy a canvas item. It almost seems like an
oversite, but maybe there is a way that is not obvious.
>
> 2) How can I add a pixmap into the canvas instead of this ellipse. I
> tried to use :
>
> pixmap = GnomePixmap()
> pixmap.load_file('generic.xpm',-1,-1) ......... ?
>
> and
>
> win = GtkWindow()
> pix, mask = gtk.create_pixmap_from_xpm(win, None, "generic.xpm")
> pixmap = gtk.GtkPixmap(pix, mask)
> win.add(pixmap)
> new_node = self.canvas.root().add( <== ? (and what is
> the anchor argument in the
>
> GnomeCanvasGroup ?)
> ...but no success.
I use the GdkImlib module, because it provides some extra functionality. In
this example, I add an image and call it an icon:
--------8<--------
from GdkImlib import *
# bla bla bla
icon = Image('icon.xpm')
icon_item = canvas.root().add('image',
image=icon._im,
x=10,
y=10,
width=icon.rgb_width,
height=icon.rgb_height,
anchor=ANCHOR_SOUTH)
--------8<--------
ANCHOR_SOUTH means x=10,y=10 will be at the bottom center. You can also use
ANCHOR_CENTER, etc.
:-)
Jeff
--
J.W. Bizzaro mailto:[EMAIL PROTECTED]
Boston College Chemistry http://www.uml.edu/Dept/Chem/Bizzaro/
--
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]