Re: Dia Python



At 21:23 15.01.03 -0600, Lars Clausen wrote:

As can be seen from my TWiki comments, I have gotten the Python plugin to
work, and it's rather cute, in fact.  Now I've two fairly general questions
about it that I hope somebody here can answer (Hans? James?):

1)  How do I set a value in a property?  I tried with just 

             props[s].value = 0.2

Try:
        obj.properties[s] = 0.2

See:
        pug-ins/python/pydia-properties.c:PyDiaProperties_AssSub
for the implementation.

   where s is a property key, but it gives me a type error.  Of course,
   DiaProperty.value is an object, but how do I make an object for a real?

Looking deeper into the code PyDiaProperty_ApplyToObject there
may be some C programming needed to get the above to work :)

All my Dia Python scripts did work without applying other
things than strings.

2)  If I do changes values that way, will it be undoable?  I don't see a
   lot of undo-related stuff in the python plugin code, does that need to
   be rewritten?  I'd like to avoid the situation in Gimp where plugins
   can totally screw up undo.

To me it appears rather useless to let every single line of a script
being undoable: At least as a user I'd expect one operation (executing
a menu function, no matter if it's a plug-in or not) to be
undoable in one step.
Forcing the creation of new object and changeing their values to
be undoable would probably decrease PyDia performance about 50% ...

But in fact I almost know nothing about Dias undo implementation.
Are 'undo groups' possible with the current code ?

        Hans
-------- 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]