vIPer is now using IPython.nbconvert
As you know (if not, probably the following lines gives you an idea), vIPer was originally designed to export from ipynb files to:
- a plain static html
- a slideshow powered by Landslide
With the last release, IPython support this kind of exportation using the well designed and easily extensible
IPython.nbconvert library. Now, it is easier to incorporate the IPython machinery inside vIPer and support the exportation to several formats.
Note: if you want to know more about vIPer, just see the following talk I gave about it at SciPy 2013.
Up to now, I have replaced the old converters by the new ones: the
HTMLExporter and the
IPython.nbconvert. As a consequence, vIPer now supports the generation of IPython slides (deprecating the use of Landslide to get the html-powered slideshow... thank you very much to the Landslide developers for their work... and to make my life easier at the first days of vIPer).
Remarkably, trying to serve the IPython slides inside vIPer was very educational, because
IPython.nbconvert already supports the serve of the resulting slides, so I tried to use this functionality and, because I needed to work in parallel, this led me to work a little bit with
So, I essentially sub-classed the
class ServeThread(QtCore.QThread): def __init__(self, extension, container): QtCore.QThread.__init__(self) self.container = container self.extension = extension def run(self): localO = self.container.titleHistory[-1] + self.extension self.container.server.open_in_browser = False self.container.server(str(self.container.path) + '/' + localO)
Note: yes, I have to deal with the path in a better way, but I am too lazy to do it now ;-)
And then, I have instantiated the
ServerThread class accordingly to my needs:
class Converter: def __init__(self, exporter, extension, container): self.container = container self.extension = extension self.exporter = exporter self.container.nbConverter(self.exporter, self.extension) self.container.servePool.append(ServeThread(self.extension, self.container)) if len(self.container.servePool) == 1: self.container.servePool.start() else: pass
It is important to highlight that I needed to call the
start() method to run the
run() method from the
And now, vIPer support serving the IPython slides automatically after the conversion step with just a click of a button.
OK, just try vIPer (Github repo) and let me know any bug... and I hope you find the Qt-derived threads information useful, or at least, interesting! ;-)
Did you like the content? Great!
Or visit my support page for more information.
Btw, don't forget this blog post is an ipynb file itself! So, you can download it from the "Source" link at the top of the post if you want to play with it ;-)Comments powered by Disqus