Ejemplo n.º 1
0
 def save_data(self, filename=None):
     """Save data"""
     if filename is None:
         filename = self.filename
         if filename is None:
             filename = getcwd()
         filename, _selfilter = getsavefilename(self, _("Save data"),
                                                filename,
                                                iofunctions.save_filters)
         if filename:
             self.filename = filename
         else:
             return False
     QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
     QApplication.processEvents()
     if self.is_internal_shell:
         wsfilter = self.get_internal_shell_filter('picklable',
                                                   check_all=True)
         namespace = wsfilter(self.shellwidget.interpreter.namespace).copy()
         error_message = iofunctions.save(namespace, filename)
     else:
         settings = self.get_view_settings()
         error_message = monitor_save_globals(self._get_sock(),
                                              settings, filename)
     QApplication.restoreOverrideCursor()
     QApplication.processEvents()
     if error_message is not None:
         QMessageBox.critical(self, _("Save data"),
                         _("<b>Unable to save current workspace</b>"
                           "<br><br>Error message:<br>%s") % error_message)
     self.save_button.setEnabled(self.filename is not None)
Ejemplo n.º 2
0
 def save_data(self, filename=None):
     """Save data"""
     if filename is None:
         filename = self.filename
         if filename is None:
             filename = os.getcwdu()
         filename = iofunctions.get_save_filename(self, filename,
                                                  self.tr("Save data"))
         if filename:
             filename = unicode(filename)
             self.filename = filename
         else:
             return False
     sock = self.shellwidget.monitor_socket
     settings = get_settings()
     error_message = monitor_save_globals(sock, settings, filename)
     if error_message is not None:
         QMessageBox.critical(self, self.tr("Save data"),
                         self.tr("<b>Unable to save current workspace</b>"
                                 "<br><br>Error message:<br>%1") \
                         .arg(error_message))
     self.save_button.setEnabled(self.filename is not None)