On Thu, 16 Jan 2003, Hans Breuer wrote: > 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.
Ah. That would explain it. I could take a look, but my Python experience is very limited. >>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. Oh, absolutely. There should probably be a wrapper around the script call that marks an undo group. > Forcing the creation of new object and changeing their values to > be undoable would probably decrease PyDia performance about 50% ... We shouldn't need to make Python objects for the undo. And I'm more concerned about this working correctly than the performance. Have you seen how scripts in Gimp affect undo? Some can be undo, some are undone in steps, some can't be undone at all, some mess up everything when trying to undo. > But in fact I almost know nothing about Dias undo implementation. > Are 'undo groups' possible with the current code ? Very much so. Undo elements are very small and must be grouped. For instance, modify_releate in app/modify_tool.c shows how undo_set_transactionpoint marks how much to undo at a time. It's quite a bit, actually. It's curious, BTW, that when the Python plug-in is in use, ^C doesn't break out of the program anymore. -Lars -- Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause)| H�rdgrim of Numenor "I do not agree with a word that you say, but I |---------------------------- will defend to the death your right to say it." | Where are we going, and --Evelyn Beatrice Hall paraphrasing Voltaire | what's with the handbasket? _______________________________________________ Dia-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/dia-list FAQ at http://www.lysator.liu.se/~alla/dia/faq.html Main page at http://www.lysator.liu.se/~alla/dia
