def __init__(self, parent=None, argv=None): # State variables self.signal_type_ag = None self.signal_datatype_ag = None self._plugin_manager_widget = None super(MainWindow, self).__init__(parent) # Set window icon self.setWindowIcon( QIcon(os.path.dirname(__file__) + '/images/hyperspy.svg')) # Parse any command line options self.parse_args(argv) # All good! self.set_status("Ready") # Redirect streams (wait until the end to not affect during load) self.settings.set_default('output_to_console', False) if self.settings['output_to_console', bool]: self._old_stdout = sys.stdout self._old_stderr = sys.stdout sys.stdout = self.console.kernel.stdout sys.stderr = self.console.kernel.stderr else: self._old_stdout = self._old_stderr = None logger.info("Main window loaded!") # Set the UI in front of other applications self.show() self.raise_()
def __init__(self, parent=None): # State variables self.signal_type_ag = None self.signal_datatype_ag = None self._plugin_manager_widget = None super(MainWindow, self).__init__(parent) # Set window icon self.setWindowIcon(QIcon(os.path.dirname(__file__) + '/images/hyperspy.svg')) # Parse any command line options self.parse_args() # All good! self.set_status("Ready") # Redirect streams (wait until the end to not affect during load) self.settings.set_default('output_to_console', False) if self.settings['output_to_console', bool]: self._old_stdout = sys.stdout self._old_stderr = sys.stdout sys.stdout = self.console.kernel.stdout sys.stderr = self.console.kernel.stderr else: self._old_stdout = self._old_stderr = None logger.info("Main window loaded!")
def get_selected_plot(self): """ Returns the selected signal; a string specifying whether the active window is "navtigation" plot, "signal" plot or "other"; and finally the active window. """ s = self.get_selected_wrapper() if s is None: logger.info("No plot available.") return w = self.main_frame.activeSubWindow() if w is s.navigator_plot: selected = "navigation" elif w is s.signal_plot: selected = "signal" else: selected = "other" return s, selected, w
def __init__(self, splash, parent=None, argv=None): self.splash = splash # State variables self.signal_type_ag = None self.signal_datatype_ag = None self._plugin_manager_widget = None self._load_signal_types() super(MainWindow, self).__init__(parent) # Set window icon self.setWindowIcon( QtGui.QIcon( os.path.join(os.path.dirname(__file__), 'images', 'hyperspy.svg'))) # Parse any command line options self.parse_args(argv) # All good! self.set_status("Ready") # Redirect streams (wait until the end to not affect during load) self.settings.set_default('output_to_console', False) if self.settings['output_to_console', bool]: self._old_stdout = sys.stdout self._old_stderr = sys.stdout sys.stdout = self.console.kernel.stdout sys.stderr = self.console.kernel.stderr else: self._old_stdout = self._old_stderr = None logger.info("Main window loaded!") # Set the UI in front of other applications self.show() self.raise_() # Workaround to bring the floating console to the front with pyqt5 if self._console_dock.isFloating(): self._console_dock.setFloating(True)
def __init__(self, splash, parent=None, argv=None): self.splash = splash # State variables self.signal_type_ag = None self.signal_datatype_ag = None self._plugin_manager_widget = None self._load_signal_types() super(MainWindow, self).__init__(parent) # Set window icon self.setWindowIcon(QtGui.QIcon(os.path.join(os.path.dirname(__file__), 'images', 'hyperspy.svg'))) # Parse any command line options self.parse_args(argv) # All good! self.set_status("Ready") # Redirect streams (wait until the end to not affect during load) self.settings.set_default('output_to_console', False) if self.settings['output_to_console', bool]: self._old_stdout = sys.stdout self._old_stderr = sys.stdout sys.stdout = self.console.kernel.stdout sys.stderr = self.console.kernel.stderr else: self._old_stdout = self._old_stderr = None logger.info("Main window loaded!") # Set the UI in front of other applications self.show() self.raise_() # Workaround to bring the floating console to the front with pyqt5 if self._console_dock.isFloating(): self._console_dock.setFloating(True)
def save(self, signals=None, filenames=None): logger.debug("entering save(), with args: %s, %s", str(signals), str(filenames)) if signals is None: signals = self.get_selected_wrappers() logger.debug("No signals passed, saving selection: %s", str(signals)) extensions = self.get_accepted_extensions() type_choices = ';;'.join(["*." + e for e in extensions]) type_choices = ';;'.join(("All types (*.*)", type_choices)) logger.debug("Save type choices: %s", type_choices) i = 0 overwrite = None for s in signals: # Match signal to filename. If filenames has not been specified, # or there are no valid filename for curren signal index i, we # have to prompt the user. if filenames is None or len( filenames) <= i or filenames[i] is None: path_suggestion = self.get_signal_filepath_suggestion(s) logger.debug("No filenames passed. Auto-suggestion: %s", path_suggestion) filename = self.prompt_files(type_choices, path_suggestion, False) # Dialog should have prompted about overwrite overwrite = True if not filename: logger.info("Not saving signal %s", str(s)) continue else: filename = filenames[i] overwrite = None # We need to confirm overwrites i += 1 s.signal.save(filename, overwrite)
def myexcepthook(exctype, value, traceback): if exctype == ProcessCanceled: logger.info("User cancelled operation") else: sys.__excepthook__(exctype, value, traceback)
def get_selected_signal(self): sw = self.get_selected_wrapper() if sw is None: logger.info("No signal available.") else: return sw.signal
def get_selected_signals(self): try: return [s.signal for s in self.get_selected_wrappers()] except AttributeError: logger.info("No signal available.")