|
From: Abraham S. <ab...@cn...> - 2004-08-13 22:08:23
|
Hi, I searched for material related to this, but didn't find any, so I
hope this isn't a repeat. One feature that has been missing from
matplotlib that I find really useful is to print my graphs (I generate a
lot, and generally want a hard copy, but not a lot of random files lying
around). While on a unix system this is easy to do, I realize it is
rather difficult to make crossplatform. So instead I've been hacking the
source and adding my own button in. However, with each release this can
get a bit tiresome, so the idea occured to me that it would be nice if I
have a function to add buttons to the toolbar that could then run
arbritrary code.
I can submit my code if anyone is interested (it's a very rough hack,
and only for the GTK backend), but the idea is that in my own code I can
just do:
def myprint(*args, **kwargs):
fd, path = tempfile.mkstemp(suffix=".eps", dir="/tmp")
savefig(path)
print "lpr %s" % path
os.system("lpr %s" % path)
os.close(fd)
os.unlink(path)
and later on:
add_toolbar_button("print", "prints figure", gtk.STOCK_PRINT, myprint)
I was curious as to what other people thought of this, and whether it
had a chance of ending up in matplotlib (being able to add other widgets
besides buttons would be extra cool).
Abe
p.s. Matplotlib is great! Never having to go near matlab again makes me
happy just thinking about it. Thanks for the great work!
|