def __init__(self, args, qapp, **kwds): """ Constructor. Takes a QApplication in the constructor to allow for easier testing with unittest. Input args: args: Command line arguments qapp: QApplication """ super(PeacockApp, self).__init__(**kwds) # don't include args[0] since that is the executable name parser = argparse.ArgumentParser(description='MOOSE GUI Application') PeacockMainWindow.commandLineArgs(parser) parsed_args = parser.parse_args(args) peacock_dir = os.path.dirname(os.path.realpath(__file__)) icon_path = os.path.join(peacock_dir, "icons", "peacock_logo.ico") qapp.setWindowIcon(QIcon(icon_path)) qtutils.setAppInformation("peacock_peacockapp") if parsed_args.exodus or parsed_args.postprocessors or parsed_args.vectorpostprocessors: # If the user wants to view files then don't try to automatically find an executable. # This should help speed up startup times. parsed_args.exe_search = False self.main_widget = PeacockMainWindow() self.main_widget.initialize(parsed_args) self.main_widget.show() self.main_widget.raise_() input_plugin = self.main_widget.tab_plugin.InputFileEditorWithMesh tree = input_plugin.InputFileEditorPlugin.tree exe_plugin = self.main_widget.tab_plugin.ExecuteTabPlugin exodus_plugin = self.main_widget.tab_plugin.ExodusViewer pp_plugin = self.main_widget.tab_plugin.PostprocessorViewer vpp_plugin = self.main_widget.tab_plugin.VectorPostprocessorViewer if parsed_args.vectorpostprocessors: self.main_widget.setTab(vpp_plugin.tabName()) elif parsed_args.postprocessors: self.main_widget.setTab(pp_plugin.tabName()) elif parsed_args.exodus: self.main_widget.setTab(exodus_plugin.tabName()) elif tree.app_info.valid(): if tree.input_filename and parsed_args.auto_run: self.main_widget.setTab(exe_plugin.tabName()) # These processEvents() seem to be needed on linux so # that the ExodusViewer gets updated properly qapp.processEvents() exe_plugin.ExecuteRunnerPlugin.runClicked() qapp.processEvents() self.main_widget.setTab(exodus_plugin.tabName()) qapp.processEvents() else: self.main_widget.setTab(input_plugin.tabName()) else: self.main_widget.setTab(exe_plugin.tabName()) self.main_widget.setPythonVariable("PeacockApp", self)
def setUp(self): """ Creates a window attached to FilePlugin widget. """ message.MOOSE_TESTING_MODE = True qtutils.setAppInformation("peacock_backgroundplugin") settings = QtCore.QSettings() settings.clear() settings.sync()
def setUp(self): """ Loads an Exodus file in the VTKWindowWidget object using a structure similar to the ExodusViewer widget. """ message.MOOSE_TESTING_MODE = True qtutils.setAppInformation("peacock_exodusviewer") settings = QtCore.QSettings() settings.clear() settings.sync() self._widget, self._main_window = main(size=[400,400]) self._widget.onSetFilenames([self._filename]) # Start with 'diffused' variable self._widget.currentWidget().FilePlugin.VariableList.setCurrentIndex(2) self._widget.currentWidget().FilePlugin.VariableList.currentIndexChanged.emit(2)
def __init__(self, args, qapp=None, **kwds): """ Constructor. Takes a QApplication in the constructor to allow for easier testing with unittest. Input args: args: Command line arguments qapp: QApplication """ super(PeacockApp, self).__init__(**kwds) # don't include args[0] since that is the executable name parser = argparse.ArgumentParser(description='MOOSE GUI Application') PeacockMainWindow.commandLineArgs(parser) parsed_args = parser.parse_args(args) peacock_dir = os.path.dirname(os.path.realpath(__file__)) icon_path = os.path.join(peacock_dir, "icons", "peacock_logo.ico") if qapp is None: qapp = QApplication.instance() qapp.setWindowIcon(QIcon(icon_path)) qtutils.setAppInformation("peacock_peacockapp") if parsed_args.exodus or parsed_args.postprocessors or parsed_args.vectorpostprocessors: # If the user wants to view files then don't try to automatically find an executable. # This should help speed up startup times. parsed_args.exe_search = False self.main_widget = PeacockMainWindow() self.main_widget.initialize(parsed_args) self.main_widget.show() self.main_widget.raise_() input_plugin = self.main_widget.tab_plugin.InputFileEditorWithMesh tree = input_plugin.InputFileEditorPlugin.tree exe_plugin = self.main_widget.tab_plugin.ExecuteTabPlugin exodus_plugin = self.main_widget.tab_plugin.ExodusViewer pp_plugin = self.main_widget.tab_plugin.PostprocessorViewer vpp_plugin = self.main_widget.tab_plugin.VectorPostprocessorViewer # issue #9255 # For some unknown reason, the Execute tab doesn't work # properly on Mac low resolution displays (and some widgets # on the input tab ). # If you switch to the ExodusViewer tab then back again, it works. # If the Execute tab is created after the ExodusViewer # tab, it works. If the VTKWindowPlugin of the ExodusViewer # tab is removed, it works. So there is some resizing issue # or something. # This ugly hack seems to fix the immediate problem. if sys.platform == 'darwin': for idx in range(self.main_widget.tab_plugin.count()): self.main_widget.tab_plugin.setCurrentIndex(idx) if parsed_args.vectorpostprocessors: self.main_widget.setTab(vpp_plugin.tabName()) elif parsed_args.postprocessors: self.main_widget.setTab(pp_plugin.tabName()) elif parsed_args.exodus: self.main_widget.setTab(exodus_plugin.tabName()) elif tree.app_info.valid(): if tree.input_filename and parsed_args.auto_run: self.main_widget.setTab(exe_plugin.tabName()) # These processEvents() seem to be needed on linux so # that the ExodusViewer gets updated properly qapp.processEvents() exe_plugin.ExecuteRunnerPlugin.runClicked() qapp.processEvents() self.main_widget.setTab(exodus_plugin.tabName()) qapp.processEvents() else: self.main_widget.setTab(input_plugin.tabName()) else: self.main_widget.setTab(exe_plugin.tabName()) self.main_widget.setPythonVariable("PeacockApp", self)
self.max_recent_spinbox = spin self.setup() def save(self, settings): """ Save the settings. Input: settings: QSettings() """ val = self.max_recent_spinbox.value() settings.setValue(self.MAX_RECENT_KEY, val) def load(self, settings): """ Load the settings. Input: settings: QSettings() """ val = settings.value(self.MAX_RECENT_KEY, type=int) if val == None: val = self.MAX_RECENT_DEFAULT self.max_recent_spinbox.setValue(val) if __name__ == "__main__": from PyQt5.QtCore import QSettings from peacock.utils import qtutils qtutils.setAppInformation("InputSettings") settings = QSettings() print("Max: %s" % settings.value(InputSettings.MAX_RECENT_KEY, type=int)) print("Values: %s" % settings.value(InputSettings.RECENTLY_USED_KEY, type=str))
key: str: key of the setting spinbox: QSpinbox: spinbox to set """ val = settings.value(key, type=int) if val == None: val = self.MAX_DEFAULT spinbox.setValue(val) def load(self, settings): """ Load settings. Input: settings: QSettings() object """ self._loadSpin(settings, self.RECENT_ARGS_MAX_KEY, self.max_args_spinbox) self._loadSpin(settings, self.RECENT_EXES_MAX_KEY, self.max_exes_spinbox) self._loadSpin(settings, self.RECENT_WORKING_MAX_KEY, self.max_working_spinbox) if __name__ == "__main__": from PyQt5.QtCore import QSettings from peacock.utils import qtutils qtutils.setAppInformation("ExecuteSettings") settings = QSettings() print("Working Max: %s" % settings.value(ExecuteSettings.RECENT_WORKING_MAX_KEY, type=int)) print("Working Values: %s" % settings.value(ExecuteSettings.RECENT_WORKING_KEY, type=str)) print("Exes Max: %s" % settings.value(ExecuteSettings.RECENT_EXES_MAX_KEY, type=int)) print("Exes Values: %s" % settings.value(ExecuteSettings.RECENT_EXES_KEY, type=str)) print("Args Max: %s" % settings.value(ExecuteSettings.RECENT_ARGS_MAX_KEY, type=int)) print("Args Values: %s" % settings.value(ExecuteSettings.RECENT_ARGS_KEY, type=str))
def __init__(self, args, qapp, **kwds): """ Constructor. Takes a QApplication in the constructor to allow for easier testing with unittest. Input args: args: Command line arguments qapp: QApplication """ super(PeacockApp, self).__init__(**kwds) # don't include args[0] since that is the executable name parser = argparse.ArgumentParser(description='MOOSE GUI Application') PeacockMainWindow.commandLineArgs(parser) parsed_args = parser.parse_args(args) peacock_dir = os.path.dirname(os.path.realpath(__file__)) icon_path = os.path.join(peacock_dir, "icons", "peacock_logo.ico") qapp.setWindowIcon(QIcon(icon_path)) qtutils.setAppInformation("peacock") if parsed_args.exodus or parsed_args.postprocessors or parsed_args.vectorpostprocessors: # If the user wants to view files then don't try to automatically find an executable. # This should help speed up startup times. parsed_args.exe_search = False self.main_widget = PeacockMainWindow() self.main_widget.initialize(parsed_args) self.main_widget.show() self.main_widget.raise_() input_plugin = self.main_widget.tab_plugin.InputFileEditorWithMesh tree = input_plugin.InputFileEditorPlugin.tree exe_plugin = self.main_widget.tab_plugin.ExecuteTabPlugin exodus_plugin = self.main_widget.tab_plugin.ExodusViewer pp_plugin = self.main_widget.tab_plugin.PostprocessorViewer vpp_plugin = self.main_widget.tab_plugin.VectorPostprocessorViewer if parsed_args.vectorpostprocessors: self.main_widget.setTab(vpp_plugin.tabName()) elif parsed_args.postprocessors: self.main_widget.setTab(pp_plugin.tabName()) elif parsed_args.exodus: self.main_widget.setTab(exodus_plugin.tabName()) elif tree.app_info.valid(): if tree.input_filename and parsed_args.auto_run: self.main_widget.setTab(exe_plugin.tabName()) # These processEvents() seem to be needed on linux so # that the ExodusViewer gets updated properly qapp.processEvents() exe_plugin.ExecuteRunnerPlugin.runClicked() qapp.processEvents() self.main_widget.setTab(exodus_plugin.tabName()) qapp.processEvents() elif tree.input_filename: self.main_widget.setTab(input_plugin.tabName()) else: self.main_widget.setTab(exe_plugin.tabName()) else: self.main_widget.setTab(exe_plugin.tabName()) self.main_widget.setPythonVariable("PeacockApp", self)
""" Load settings. Input: settings: QSettings() object """ self._loadSpin(settings, self.RECENT_ARGS_MAX_KEY, self.max_args_spinbox) self._loadSpin(settings, self.RECENT_EXES_MAX_KEY, self.max_exes_spinbox) self._loadSpin(settings, self.RECENT_WORKING_MAX_KEY, self.max_working_spinbox) if __name__ == "__main__": from PyQt5.QtCore import QSettings from peacock.utils import qtutils qtutils.setAppInformation("ExecuteSettings") settings = QSettings() print("Working Max: %s" % settings.value(ExecuteSettings.RECENT_WORKING_MAX_KEY, type=int)) print("Working Values: %s" % settings.value(ExecuteSettings.RECENT_WORKING_KEY, type=str)) print("Exes Max: %s" % settings.value(ExecuteSettings.RECENT_EXES_MAX_KEY, type=int)) print("Exes Values: %s" % settings.value(ExecuteSettings.RECENT_EXES_KEY, type=str)) print("Args Max: %s" % settings.value(ExecuteSettings.RECENT_ARGS_MAX_KEY, type=int)) print("Args Values: %s" % settings.value(ExecuteSettings.RECENT_ARGS_KEY, type=str))