J
Jacob Kroon
I'm writing a block-diagram editor, and could use some tips about
writing/reading
diagrams to/from an xml file format. The basic layout of my code :
class Diagram {
Blocks blocks[]
}
class Block {
int x, y
}
class Square(Block) {
int width, height
}
class Circle(Block) {
int radius
}
I'd like to be able to output something similar to this:
<diagram>
<square x='12' y='34' width='50' height='40'/>
<circle x='40' y='60' radius='20/>
</diagram>
One idea I had was to make Diagram and Block derive from
xml.dom.minidom.Element,
and then somehow catch when I set an attribute, so that setAttribute()
gets called with correct
arguments. Perhaps then I could just do a simple diagram.toprettyxml().
Anyone have a good idea on how to approach this problem ?
(I do not want to use the pickle module)
/Jacob Kroon
writing/reading
diagrams to/from an xml file format. The basic layout of my code :
class Diagram {
Blocks blocks[]
}
class Block {
int x, y
}
class Square(Block) {
int width, height
}
class Circle(Block) {
int radius
}
I'd like to be able to output something similar to this:
<diagram>
<square x='12' y='34' width='50' height='40'/>
<circle x='40' y='60' radius='20/>
</diagram>
One idea I had was to make Diagram and Block derive from
xml.dom.minidom.Element,
and then somehow catch when I set an attribute, so that setAttribute()
gets called with correct
arguments. Perhaps then I could just do a simple diagram.toprettyxml().
Anyone have a good idea on how to approach this problem ?
(I do not want to use the pickle module)
/Jacob Kroon