Script for Math drawing — April 29, 2013

Script for Math drawing

Here is a quick and dirty script for drawing math pictures I use when solving problems. An example picture:

Usually I use this script attached to a hotkey in conjunction with pinta (basically MS paint) on linux. It gives a prompt where you can enter latex. Then it puts the latex into your clipboard as a png file so you can paste it into paint. The end result? paint with latex. The reason I wrote this is because the inkscape / latex plugin I used to use was too resource heavy and slow for when solving problems.

a = io.popen(“zenity –entry”):read(“*a”)
b = string.gsub(a, “\n”, “”)
os.execute(“/home/andrew/mathtex.cgi \””..b..”\” -o textmp”)
os.execute(“python /home/andrew/”)

Also you will need (I found the bulk of this script somewhere else on the web a long time ago and have forgotten the source):
#! /usr/bin/python

import pygtk
import gtk
import os
import sys

def copy_image(f):
assert os.path.exists(f), “file does not exist”
image = gtk.gdk.pixbuf_new_from_file(f)

clipboard = gtk.clipboard_get()