From c4ce2ea95ade54089e3ddb0eb24d5cc20a8bab22 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 28 Jan 2009 12:51:39 +0900 Subject: [PATCH] Make grapher export image file. Currently dangerous with no error checking. Exports a png file in the same dimensions as it appears on screen --- pyfpdb/GuiGraphViewer.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index be9efe42..82f6d4fa 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -282,13 +282,18 @@ class GuiGraphViewer (threading.Thread): dia_chooser = gtk.FileChooserDialog(title="Please choose the directory you wish to export to:", action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) + #TODO: Suggest path and filename to start with response = dia_chooser.run() if response == gtk.RESPONSE_OK: self.exportDir = dia_chooser.get_filename() + print "DEBUG: self.exportDir = %s" %(self.exportDir) elif response == gtk.RESPONSE_CANCEL: print 'Closed, no graph exported' dia_chooser.destroy() + #TODO: Check to see if file exists + #NOTE: Dangerous - will happily overwrite any file we have write access too + self.fig.savefig(self.exportDir, format="png") def __init__(self, db, settings, querylist, config, debug=True): """Constructor for GraphViewer"""