예제 #1
0
 def save_data(self, filename=None):
     """Save data"""
     if filename is None:
         filename = self.filename
         if filename is None:
             filename = os.getcwdu()
         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)
예제 #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, _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)
     
예제 #3
0
파일: shell.py 프로젝트: koll00/Gui_SM
 def save_historylog(self):
     """Save current history log (all text in console)"""
     title = _("Save history log")
     self.emit(SIGNAL('redirect_stdio(bool)'), False)
     filename, _selfilter = getsavefilename(self, title,
                 self.historylog_filename, "%s (*.log)" % _("History logs"))
     self.emit(SIGNAL('redirect_stdio(bool)'), True)
     if filename:
         filename = osp.normpath(filename)
         try:
             encoding.write(unicode(self.get_text_with_eol()), filename)
             self.historylog_filename = filename
             CONF.set('main', 'historylog_filename', filename)
         except EnvironmentError, error:
             QMessageBox.critical(self, title,
                                  _("<b>Unable to save file '%s'</b>"
                                    "<br><br>Error message:<br>%s"
                                    ) % (osp.basename(filename),
                                         unicode(error)))
예제 #4
0
파일: explorer.py 프로젝트: koll00/Gui_SM
 def create_new_file(self, current_path, title, filters, create_func):
     """Create new file
     Returns True if successful"""
     if current_path is None:
         current_path = ''
     if osp.isfile(current_path):
         current_path = osp.dirname(current_path)
     self.parent_widget.emit(SIGNAL('redirect_stdio(bool)'), False)
     fname, _selfilter = getsavefilename(self, title, current_path, filters)
     self.parent_widget.emit(SIGNAL('redirect_stdio(bool)'), True)
     if fname:
         try:
             create_func(fname)
             return fname
         except EnvironmentError, error:
             QMessageBox.critical(
                 self, _("New file"),
                 _("<b>Unable to create file <i>%s</i>"
                   "</b><br><br>Error message:<br>%s") %
                 (fname, unicode(error)))
예제 #5
0
파일: shell.py 프로젝트: koll00/Gui_SM
 def save_historylog(self):
     """Save current history log (all text in console)"""
     title = _("Save history log")
     self.emit(SIGNAL('redirect_stdio(bool)'), False)
     filename, _selfilter = getsavefilename(
         self, title, self.historylog_filename,
         "%s (*.log)" % _("History logs"))
     self.emit(SIGNAL('redirect_stdio(bool)'), True)
     if filename:
         filename = osp.normpath(filename)
         try:
             encoding.write(unicode(self.get_text_with_eol()), filename)
             self.historylog_filename = filename
             CONF.set('main', 'historylog_filename', filename)
         except EnvironmentError, error:
             QMessageBox.critical(
                 self, title,
                 _("<b>Unable to save file '%s'</b>"
                   "<br><br>Error message:<br>%s") %
                 (osp.basename(filename), unicode(error)))
예제 #6
0
파일: explorer.py 프로젝트: koll00/Gui_SM
 def create_new_file(self, current_path, title, filters, create_func):
     """Create new file
     Returns True if successful"""
     if current_path is None:
         current_path = ""
     if osp.isfile(current_path):
         current_path = osp.dirname(current_path)
     self.parent_widget.emit(SIGNAL("redirect_stdio(bool)"), False)
     fname, _selfilter = getsavefilename(self, title, current_path, filters)
     self.parent_widget.emit(SIGNAL("redirect_stdio(bool)"), True)
     if fname:
         try:
             create_func(fname)
             return fname
         except EnvironmentError, error:
             QMessageBox.critical(
                 self,
                 _("New file"),
                 _("<b>Unable to create file <i>%s</i>" "</b><br><br>Error message:<br>%s")
                 % (fname, unicode(error)),
             )