Re: python plugin and object properties



At 17:01 30.06.01 +0200, Michael Maluck wrote:
Hi all,

tried to get some object properties of "UML Class" objects in the
python dia console.

i comiled dia 0.88.1 from source with the --with-python option.
dia.active_display().diagram.layers[0].properties.get("obj_pos") returns
always None.
Doesn't it give a runtime-error AttributeError: properties ?

dia.active_display().diagram.layers[0].objects[0].properties['obj_pos'].value

works:

<DiaPoint object at ...>

[Though there are probably Dia objects, which do not support the property
api yet] 
The has_key method says that the property exists. It is also listed
in keys().
The main problem is, that the layer object has no properties, because it
isn't a DiaObject as one may expect. The property api is only supported by
most objects within the diagram, like

dia.active_display().diagram.layers[0].objects[0].type
<DiaObjectType 'Standard - Text'>

i doesn't matter which property i want to get. it doesn't work for all.
any ideas?

There is probably no senseful way to write Dia Extensions in Python without
being able to read and understand the C-Sources

are there any docs for the python plugin?
NAFAIK. I've attached a small interface description extracted from the
C-Source, no real documentation :(

is it possible to use the dia api not only in the python dia console?

Yes. There are two examples how to write an export filter in Python, but
again I don't think it would be much fun to write one, without being able
to debug or 'investigate the limitations in' the Python-Plugin as well.

The Plugin will probably remain such limited as it is, at least until it
(and first the Dia Object System) is converted to Gtk+2.0 especially the
GObject system, because the current access does not allow to ref-count the
objects, to easily back-propagate property changes, etc. ...

        Hans

Attachment: pydia.txt
Description: Text document


-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to 
get along without it.                -- Dilbert


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