[Edu-sig] Edu-sig Digest, Vol 116, Issue 4

Lee Harr missive at hotmail.com
Sun Mar 17 22:34:30 CET 2013


> Lee, if you are looking for a classroom teacher to try out pynguin in
> the classroom, sign me up!  I'll have it installed in my lab on
> Thursday, when I return, in any case.  It rocks!

Thanks! Glad to hear it!


> Now a question:  how difficult would it be to get pynguin to output svg images?

Turns out with QGraphicsScene it's actually pretty easy.
Try replacing the MainWindow.export() method in mw.py with this:


    def export(self):

        for pynguin in self.pynguins:
            pynguin.gitem.hide()

        from PyQt4 import QtSvg
        svgen = QtSvg.QSvgGenerator()
        svgen.setFileName('test.svg')
        svgen.setSize(QtCore.QSize(500, 500))
        svgen.setViewBox(QtCore.QRect(-250, -250, 500, 500))
        svgen.setTitle('Test SVG Output')
        svgen.setDescription('PyQt SVG Generator')
        painter = QtGui.QPainter(svgen)
        self.scene.render(painter)
        painter.end()

        for pynguin in self.pynguins:
            pynguin.gitem.show()



It's just a proof-of-concept, but it definitely works.

Thanks for the suggestion. I will look at adding that
option for the next release.

 		 	   		  


More information about the Edu-sig mailing list