Python Sript Related Questions



Hello All

I recently joined the Dia mailing list and i have some questions regarding the scripting capability using python. Yes, i have searched the mailing list for answers to my questions and i did not find any, Yes i might be using the wrong words for what i want :-)

1)
I am using Dia 0.94, What i am trying to do is to change the property of an element. I have looked at the example scripts but there is no clear explanation of how to do it. What i am trying to do is this:

import dia

Objects=dia.active_display().diagram.active_layer.objects;

#So far so good, now let me change a color

CurObj.properties["fill_colour"].value.red=0.0

And here is where i get the
TypeError: 'DiaColor' object has only read-only attributes (assign to .red)

What does it mean when it says (assign to .red) ? I AM trying to assign it to .red (I have also tried blah..blah.red=float(0.0) and blah..blah.red="1.0" with no luck :-( )

Then i tried to do something like:
CurObj.properties["fill_colour"].value=DiaColor(0,0,0)

Which did not work as well because i can not instantiate DiaColor (Anything similar to type casting with Python that i am not aware of?)

2)
Is there a way to completely reload a package in Python? I hate to restart Dia everytime i am making a change to my script.


3)
How does the dia.register_* family of functions works? I mean, i am assigning a function to a particular menu item but it does not appear there :-/ am i missing something there?


Looking forward to hearing from you
thanOS



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