Some python fun for presentations
The post contains ultimate off-topic, so the source code is here 🙂 : https://bitbucket.org/dpeleshenko/mdshow
Besides managing my company Kvinivel and working as a developer, I am working with students at the Kharkiv university. That is a good way to find young talents and prepare them to work in our company.
So I am very often preparing some technical presentations. I have a huge archive of presentations from different technologies. When I prepare my lectures I have to merge these presentations, update obsolete data, and so on. I was always using MS PowerPoint. But reworking presentations by drag’n’drop is terrible. Additionally, I have problems with different slide designs. So I am completely unsatisfied with existing mouse-driven presentation software.
As a developer, I prefer to write everything in problem-oriented language. The first idea was HTML… but it’s too complex… too many letters. LaTex is good, but also complex too. I have no math symbols or other similar things in my presentation. Much better is Markdown. After the presentation made with markdown become my dream. And one of the important things was to have every slide in a separate file and have a separate file for general presentation layout and design. There are some open-source solutions, but none of them was good enough for me. So I decided to make it myself.
My first idea was to convert markdown to HTML and render HTML with CEF. And taking into account that I have another dream — to develop cross-platform desktop application technology with Python business logic and HTML/CSS/JS presentation. I selected python and CEF as the main technology stack. But unfortunately, all CEF binding for python is terrible. I spent the whole day trying to run the demo code without any success.
After some additional research, I have found a very good library to statically render HTML/CSS – http://weasyprint.org/ That was completely enough for me. You can find a python script with about 120 lines to show presentations based on the directory with markdown files here: https://bitbucket.org/dpeleshenko/mdshow
To run this code, you will need to install the following:
- WeasyPrint (
pip install WeasyPrint
) - Markdown ( ‘pip install markdown’ )
- PyGTK and GTK http://www.pygtk.org/index.html
I have tested everything in Ubuntu 15.10, but everything should work in any Linux, Mac, or Windows. Maybe some fine-tuning with GTK will be required.