Saturday, January 30, 2010

PyQt4 Schema Script

I've received a couple of emails asking me what I use to draw various graphs and schema that I post on this blog. And the obviously answer is QPainter! I've a small PyQt script that does the easy things but the more difficult one is coded every time...


The script is really simple, it take an xml input and just draw the few items that can recognize. You can use RGBA colors and you can draw linee-paths, like in the image above. The XML looks like this one:



<!-- Green Rect -->
<item type='rectangle'
x='130' y='140' width='140' height='60' 
border='1/0x98b954' 
color='0xf4ffe4/0xdbfdab' />

<text x='130' y='140' width='140' height='60'
color='0x000000' font='Arial'
size='12' bold='false' italic='true'>
I'm just a Test!
</text>        

<!-- Links Line -->
<line path='70,120;70,170;130,170' />



I know that it's a stupid thing and making xml seems to be a long job, but this is what I need at the moment, maybe in the future this script will get a WYSIWYG ui but at this time is just a simple script that generate an image :)

The source code with the above example is available here: PyQt4 Schema Script.

1 comment:

  1. It looks very nice indeed! With PDF output and support for multiple images, you could start writing your own presentation application. :-)

    ReplyDelete