Save plot enabled
This commit is contained in:
parent
a7c60ffe64
commit
1863bfc564
|
@ -1537,6 +1537,14 @@ class PlotToolbar(gtk.Toolbar):
|
|||
self.insert(gtk.SeparatorToolItem(), -1)
|
||||
self.set_style(gtk.TOOLBAR_ICONS)
|
||||
|
||||
# Set up freeze button
|
||||
btn = gtk.ToolButton(gtk.STOCK_SAVE)
|
||||
|
||||
#btn.set_icon_widget(image)
|
||||
btn.connect('clicked', self._on_save_clicked)
|
||||
self.insert(btn, -1)
|
||||
self.save_button = btn
|
||||
|
||||
# Set up freeze button
|
||||
btn = gtk.ToggleToolButton()
|
||||
|
||||
|
@ -1616,6 +1624,23 @@ class PlotToolbar(gtk.Toolbar):
|
|||
if button.get_active():
|
||||
self.set_mode(self._mode_buttons[button].name)
|
||||
|
||||
def _on_save_clicked(self, button):
|
||||
"""Pops up a file dialog saver, and saves current plot"""
|
||||
dialog = gtk.FileChooserDialog('Save plot')
|
||||
dialog.set_action(gtk.FILE_CHOOSER_ACTION_SAVE)
|
||||
dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)
|
||||
default_name = "fluents_image"
|
||||
dialog.set_current_name("%s.png" % default_name)
|
||||
retval = dialog.run()
|
||||
if retval in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
|
||||
logger.log("debug", "Cancelled save plot")
|
||||
elif retval == gtk.RESPONSE_OK:
|
||||
logger.log("debug", "Saving plot as: %s" % dialog.get_filename())
|
||||
self.canvas.print_figure(dialog.get_filename())
|
||||
else:
|
||||
print "unknown; ", retval
|
||||
dialog.destroy()
|
||||
|
||||
def _on_freeze_toggle(self, button):
|
||||
self.plot.set_frozen(button.get_active())
|
||||
|
||||
|
|
Reference in New Issue