simple Python plugin



Hi!!

I want to write a python plugin to automaticaly draw UML-chart based on text files. I did not find any references for such a task (writing a python plugin) so I decide to play with the examples I could find. I write the following script to simply draw a rectangle/class but it fails

import sys, dia, string

def draw_text(data, flags):

    diagram = dia.new("mytest.dia")

    layer = data.active_layer

    ot = dia.get_object_type("UML - Class")
    o, h1, h2 = ot.create (10, 10)

    o.properties["name"] = "TEST"
    o.properties["template"] = 1
    o.properties["fill_colour"] = "lightgreen"

    dia.message(2, "test3!\n")

    layer.add_object(o)

    layer.update_extents()
    data.update_extents()

    diagram.display()
    diagram.flush()

dia.register_callback("Test draw", "<Display>/Tools/Test", draw_text)

Playing with comments and dia.message it appears that my script fails on the first line "diagram = dia.new("mytest.dia")"

Can someone give some hints?

Thanks a lot!!

O.



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