Re: initializing python objects derived from gnome.canvas.CanvasItem



Ok, I finally broke down and read the code.  And it looks like the
answer is, you can't do that.

At least, not yet.

I'm working on mods to _wrap_gnome_canvas_item_new() to have it call
an initialization routine.  At first, I thought I would have it call
__init__().  But it looks like the implementers of the python wrappers
for the canvas were rather deliberate about *not* allowing a canvas
item to be instantiated by calling the class (presumably to prevent
the creation of an orphaned item).  So, in keeping with that, I'm going
to use some other name for the initialization routine.  How about
__canvas_item_init__()?

gnome-python maintainers, I welcome any input you have.  If you like
the idea, I'll send you my mods when I'm done.

phil

Quoting Phil Dumont <phil solidstatescientific com>:

> Sorry if this is a dumb question.  I'm still climbing the gtk/gnome
> learning curve.
> 
> I'm doing some gnome canvas stuff in python.  I've created a python class
> that is derived from CanvasItem.  (Not directly from CanvasItem, but from
> some of the stock canvas items: e.g., CanvasRect.)
> 
> How do I initialize it?
> 
> Defining __init__ doesn't do any good, of course, because you don't create
> new CanvasItems by calling the class, you create them by calling the add
> method, and that doesn't call init.
> 
> I think I could figure out how to do it from C -- I've found where the
> gobject class info keeps it's init routine.  But I haven't been able to
> figure out how to do it in python.
> 
> Thanks,
> 
> phil
> 






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]