Re: manipulating properties



Am Dienstag, 26. April 2005 09:29 schrieb Hans Breuer:
From: "Bernd Rößl" <bernd roessl telesis at>
Date: Tue, 26 Apr 2005 00:02:59 +0200

hello list,

i tryed to create DiaObjects by python which works fine. but when i try
to set some properties like 'name' it seams all properties are readonly.

o = dia.get_object_type("UML - Class").create(10,10)
dia.active_display().diagram.active_layer.add_object(o[0])
o[0].properties.get('name').value = "MyClass"

[...]
TypeError: 'DiaProperty' object has only read-only attributes (assign
to .value)

is there a special methode to set properties or another way to build
models by python?

Yes. o[0].properties['name'] = "MyClass"

See:
http://cvs.gnome.org/viewcvs/dia/plug-ins/python/otypes.py?rev=1.2&view=mar
kup

But only simple properties can be set, i.e. no lists like the "operations"
yet.


thanks hans,

does this mean, there is no way to add "operations" and "attributes" to a 
class-object? i'm currently try to build a plugin like a reverse engenering 
tool for python code, and i need to set operations and attributes to classes.
ok, i'm trying some things in the evening.

thanks once again and have a nice day
bernd 

-- 
telesis Entwicklungs- und Management GmbH · Hof 4 · A-6861 Alberschwende
Tel +43 5579 7171 79 · Fax -71 · Mobil +43 699 17717179
http://telesis.at/ · bernd roessl telesis at



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