Anton Shestakov <engored@ya.ru>, Sun, 14 Sep 2014 23:07:17 +0900
Split cheatsheets into vim and python, build separately.
html2png.py
Permissions: -rwxr-xr-x
class SimpleBrowser(object): # http://kmandla.wordpress.com/2010/05/24/the-1-2kb-python-browser-script/ # taken from there and adapted to be stupid and take screenshots def __init__(self, url, output_filename): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.window.connect('delete_event', self.close_application) screen = self.window.get_screen() self.webview = webkit.WebView() self.webview.set_size_request(screen.get_width(), screen.get_height()) self.window.add(self.webview) self.window.set_title('%s' % url) 'document-load-finished', self.screenshot, output_filename) def screenshot(webview, frame, output_filename): width, height = webview.window.get_size() pb = gtk.gdk.Pixbuf('rgb', False, 8, width, height) cm = gtk.gdk.colormap_get_system() pb.get_from_drawable(webview.window, cm, 0, 0, 0, 0, width, height) pb.save(output_filename, 'png') glib.timeout_add_seconds(1, callback) # delay until rendering finishes def close_application(self, widget, event, data=None): if __name__ == '__main__': SimpleBrowser(sys.argv[1], sys.argv[2]) print 'usage:', sys.argv[0], 'INPUT OUTPUT'