Ejemplo n.º 1
0
    def __init__(self):
        super(ExecuteRunnerPlugin, self).__init__()
        self.top_layout = WidgetUtils.addLayout(vertical=True)

        self.run_layout = WidgetUtils.addLayout()
        self.run_layout.addStretch()

        self.run_button = WidgetUtils.addButton(self.run_layout,
                                                None,
                                                "Run",
                                                self.runClicked,
                                                enabled=False)
        self.kill_button = WidgetUtils.addButton(self.run_layout,
                                                 None,
                                                 "Kill",
                                                 self.killClicked,
                                                 enabled=False)
        self.clear_button = WidgetUtils.addButton(self.run_layout,
                                                  None,
                                                  "Clear log",
                                                  self.clearLog,
                                                  enabled=True)
        self.save_button = WidgetUtils.addButton(self.run_layout,
                                                 None,
                                                 "Save log",
                                                 self.saveLog,
                                                 enabled=True)

        self.run_layout.addStretch()

        self.progress_layout = WidgetUtils.addLayout()
        self.progress_label = WidgetUtils.addLabel(self.progress_layout, None,
                                                   "Progress: ")
        self.progress_bar = WidgetUtils.addProgressBar(self.progress_layout,
                                                       None)
        self._showProgressBar(False)

        self.setLayout(self.top_layout)
        self.top_layout.addLayout(self.run_layout)
        self.top_layout.addLayout(self.progress_layout)

        self.runner = JobRunner()

        self._total_steps = 0
        self.runner.finished.connect(self.runFinished)
        self.runner.outputAdded.connect(self.outputAdded)
        self.runner.timeStepUpdated.connect(
            lambda t: self.runProgress.emit(t, self._total_steps))
        self.runner.started.connect(
            lambda: self.runProgress.emit(0, self._total_steps))
        self.runner.timeStepUpdated.connect(self._updateProgressBar)
        self.exe_path = None
        self.exe_args = []
        self.has_csv = False

        self.setup()
Ejemplo n.º 2
0
    def __init__(self, **kwds):
        """
        Constructor.
        """
        super(SettingsWidget, self).__init__(**kwds)

        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.setLayout(self.top_layout)
        self.tabs = QTabWidget(parent=self)
        self.top_layout.addWidget(self.tabs)
        self.button_layout = WidgetUtils.addLayout()
        self.top_layout.addLayout(self.button_layout)
        self.save_button = WidgetUtils.addButton(self.button_layout, self, "&Save", self._save)
        self.cancel_button = WidgetUtils.addButton(self.button_layout, self, "&Cancel", self._cancel)
        self.setup()
Ejemplo n.º 3
0
    def _createButtons(self):
        """
        Create allowable buttons for this Block.
        This will depend on whether this is a user added block.
        """
        self.button_layout = WidgetUtils.addLayout()

        self.close_button = WidgetUtils.addButton(self.button_layout, self, "Apply && Close", self._applyAndClose)
        self.close_button.setToolTip("Apply any changes and close the window")

        self.apply_button = WidgetUtils.addButton(self.button_layout, self, "Apply", self.applyChanges)
        self.apply_button.setEnabled(False)
        self.apply_button.setToolTip("Apply changes made")

        self.reset_button = WidgetUtils.addButton(self.button_layout, self, "Reset", self.resetChanges)
        self.reset_button.setEnabled(False)
        self.reset_button.setToolTip("Reset changes to when this window was opened")

        self.new_parameter_button = WidgetUtils.addButton(self.button_layout, self, "Add parameter", self.addUserParamPressed)
        self.new_parameter_button.setToolTip("Add a non standard parameter")

        if self.block.user_added:
            self.clone_button = WidgetUtils.addButton(self.button_layout, self, "Clone Block", self._cloneBlock)
            self.clone_shortcut = WidgetUtils.addShortcut(self, "Ctrl+N", self._cloneBlock, shortcut_with_children=True)
            self.clone_button.setToolTip("Clone this block with the same parameters")

            self.remove_button = WidgetUtils.addButton(self.button_layout, self, "Remove Block", self._removeBlock)
            self.remove_button.setToolTip("Remove this block")
 def testCreation(self):
     layout = WidgetUtils.addLayout()
     WidgetUtils.addLineEdit(layout, None, self.callback)
     WidgetUtils.addProgressBar(layout, None, callback=self.callback)
     WidgetUtils.addButton(layout, None, "Button", self.callback)
     WidgetUtils.addLabel(layout, None, "Name")
     WidgetUtils.addCheckbox(layout, None, "name", self.callback)
Ejemplo n.º 5
0
 def testCreation(self):
     layout = WidgetUtils.addLayout()
     WidgetUtils.addLineEdit(layout, None, self.callback)
     WidgetUtils.addProgressBar(layout, None, callback=self.callback)
     WidgetUtils.addButton(layout, None, "Button", self.callback)
     WidgetUtils.addLabel(layout, None, "Name")
     WidgetUtils.addCheckbox(layout, None, "name", self.callback)
Ejemplo n.º 6
0
    def _createButtons(self):
        """
        Create allowable buttons for this Block.
        This will depend on whether this is a user added block.
        """
        self.button_layout = WidgetUtils.addLayout()

        if self.block.user_added:
            self.clone_button = WidgetUtils.addButton(self.button_layout, self, "Clone Block", self._cloneBlock)
            self.clone_shortcut = WidgetUtils.addShortcut(self, "Ctrl+N", self._cloneBlock, shortcut_with_children=True)
            self.clone_button.setToolTip("Clone this block with the same parameters")

            self.remove_button = WidgetUtils.addButton(self.button_layout, self, "Remove Block", self._removeBlock)
            self.remove_button.setToolTip("Remove this block")

        self.apply_button = WidgetUtils.addButton(self.button_layout, self, "Apply", self.applyChanges)
        self.apply_button.setEnabled(False)
        self.apply_button.setToolTip("Apply changes made")

        self.reset_button = WidgetUtils.addButton(self.button_layout, self, "Reset", self.resetChanges)
        self.reset_button.setEnabled(False)
        self.reset_button.setToolTip("Reset changes to when this window was opened")

        self.new_parameter_button = WidgetUtils.addButton(self.button_layout, self, "Add parameter", self.addUserParamPressed)
        self.new_parameter_button.setToolTip("Add a non standard parameter")

        self.close_button = WidgetUtils.addButton(self.button_layout, self, "Close", self._applyAndClose)
        self.close_button.setToolTip("Apply any changes and close the window")
Ejemplo n.º 7
0
    def __init__(self, block, **kwds):
        """
        Constructor.
        Input:
            block[BlockInfo]: The block to show.
        """
        super(ParamsByType, self).__init__(**kwds)
        self.block = block
        self.combo = QComboBox()
        self.types = []
        self.type_params_map = {}
        self.table_stack = QStackedWidget()
        self.type_table_map = {}

        for t in sorted(self.block.types.keys()):
            self.types.append(t)
            params_list = []
            for p in self.block.parameters_list:
                params_list.append(self.block.parameters[p])
            t_block = self.block.types[t]
            for p in t_block.parameters_list:
                params_list.append(t_block.parameters[p])
            self.type_params_map[t] = params_list

        self.combo.addItems(sorted(self.block.types.keys()))
        self.combo.currentTextChanged.connect(self.setBlockType)

        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.top_layout.addWidget(self.combo)
        self.top_layout.addWidget(self.table_stack)
        self.setLayout(self.top_layout)
        self.user_params = []
        self.setDefaultBlockType()

        self.setup()
    def __init__(self, **kwds):
        super(CheckInputWidget, self).__init__(**kwds)

        self.input_file = "peacock_check_input.i"
        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.setLayout(self.top_layout)
        self.output = QTextBrowser(self)
        self.output.setStyleSheet("QTextBrowser { background: black; color: white; }")
        self.output.setReadOnly(True)
        self.top_layout.addWidget(self.output)
        self.button_layout = WidgetUtils.addLayout()
        self.top_layout.addLayout(self.button_layout)
        self.hide_button = WidgetUtils.addButton(self.button_layout, self, "Hide", lambda: self.hide())
        self.check_button = WidgetUtils.addButton(self.button_layout, self, "Check", self._check)
        self.resize(800, 500)
        self.setup()
        self.path = None
    def __init__(self, **kwds):
        """
        Constructor.
        """
        super(SettingsWidget, self).__init__(**kwds)

        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.setLayout(self.top_layout)
        self.tabs = QTabWidget(parent=self)
        self.top_layout.addWidget(self.tabs)
        self.button_layout = WidgetUtils.addLayout()
        self.top_layout.addLayout(self.button_layout)
        self.save_button = WidgetUtils.addButton(self.button_layout, self,
                                                 "&Save", self._save)
        self.cancel_button = WidgetUtils.addButton(self.button_layout, self,
                                                   "&Cancel", self._cancel)
        self.setup()
Ejemplo n.º 10
0
 def __init__(self, **kwds):
     """
     Constructor.
     """
     super(LogWidget, self).__init__(**kwds)
     self.top_layout = WidgetUtils.addLayout(vertical=True)
     self.setLayout(self.top_layout)
     self.log = QTextBrowser(self)
     self.log.setStyleSheet("QTextBrowser { background: black; color: white; }")
     self.log.setReadOnly(True)
     message.messageEmitter.message.connect(self._write)
     self.button_layout = WidgetUtils.addLayout()
     self.hide_button = WidgetUtils.addButton(self.button_layout, self, "Hide", lambda: self.hide())
     self.clear_button = WidgetUtils.addButton(self.button_layout, self, "Clear", lambda: self.log.clear())
     self.top_layout.addWidget(self.log)
     self.top_layout.addLayout(self.button_layout)
     self.resize(800, 500)
Ejemplo n.º 11
0
    def __init__(self, **kwds):
        super(ExecuteSettings, self).__init__(**kwds)

        self.top_layout = WidgetUtils.addLayout(grid=True)
        self.setLayout(self.top_layout)
        tmp, self.max_args_spinbox = self._addOptionToGrid("Max recent working dirs", 0)
        tmp, self.max_exes_spinbox = self._addOptionToGrid("Max recent executables", 1)
        tmp, self.max_working_spinbox = self._addOptionToGrid("Max recent arguments", 2)
        self.setup()
Ejemplo n.º 12
0
    def __init__(self, **kwds):
        super(PythonConsoleWidget, self).__init__(**kwds)

        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.setLayout(self.top_layout)
        self.output = QPlainTextEdit(parent=self)
        self.output.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.output.setReadOnly(False)
        self.output.setFocusPolicy(Qt.ClickFocus)
        self.output.setStyleSheet(
            "QPlainTextEdit { background: black; color: white;}")
        self.output.setTextInteractionFlags(Qt.TextSelectableByMouse
                                            | Qt.TextSelectableByKeyboard
                                            | Qt.LinksAccessibleByMouse
                                            | Qt.LinksAccessibleByKeyboard)
        self.top_layout.addWidget(self.output)

        self.input_layout = WidgetUtils.addLayout()
        self.top_layout.addLayout(self.input_layout)
        self.prompt = WidgetUtils.addLabel(self.input_layout, self, ">>>")

        self.input_line = WidgetUtils.addLineEdit(self.input_layout, self,
                                                  self._returnPressed)
        self.input_line.setFocusPolicy(Qt.StrongFocus)
        self.input_line.installEventFilter(self)

        self.user_inputs = []
        self.current_index = -1
        # get a list of globals and locals from the callstack
        self._global_data = {}
        self._global_data['global_vars'] = globals()
        self._global_data['peacock'] = {}
        self.console = QPythonConsole(self._global_data, parent=self)
        self.console.write_output.connect(self.output.appendPlainText)
        self.output.appendPlainText(
            "Peaock variables are in the dict 'peacock'")
        self.output.appendPlainText(
            "Global variables are in the dict 'global_vars'")
        self.console.prompt_changed.connect(self.prompt.setText)
        self.new_line.connect(self.console._newLine)
        self.console._setPrompt()
        self._loadHistory()
        self.resize(600, 400)
        self.setup()
Ejemplo n.º 13
0
    def __init__(self):
        super(ExecuteRunnerPlugin, self).__init__()

        self._preferences.addBool("execute/clearLog",
                "Clear log before running",
                False,
                "Clear the output from previous runs before starting a new run",
                )

        self.top_layout = WidgetUtils.addLayout(vertical=True)

        self.run_layout = WidgetUtils.addLayout()
        self.run_layout.addStretch()

        self.run_button = WidgetUtils.addButton(self.run_layout, None, "Run", self.runClicked, enabled=False)
        self.kill_button = WidgetUtils.addButton(self.run_layout, None, "Kill", self.killClicked, enabled=False)
        self.clear_button = WidgetUtils.addButton(self.run_layout, None, "Clear log", self.clearLog, enabled=True)
        self.save_button = WidgetUtils.addButton(self.run_layout, None, "Save log", self.saveLog, enabled=True)

        self.run_layout.addStretch()

        self.progress_layout = WidgetUtils.addLayout()
        self.progress_label = WidgetUtils.addLabel(self.progress_layout, None, "Progress: ")
        self.progress_bar = WidgetUtils.addProgressBar(self.progress_layout, None)
        self._showProgressBar(False)

        self.setLayout(self.top_layout)
        self.top_layout.addLayout(self.run_layout)
        self.top_layout.addLayout(self.progress_layout)

        self.runner = JobRunner()

        self._total_steps = 0
        self.runner.finished.connect(self.runFinished)
        self.runner.outputAdded.connect(self.outputAdded)
        self.runner.timeStepUpdated.connect(lambda t: self.runProgress.emit(t, self._total_steps))
        self.runner.started.connect(lambda : self.runProgress.emit(0, self._total_steps))
        self.runner.timeStepUpdated.connect(self._updateProgressBar)
        self.exe_path = None
        self.exe_args = []
        self.has_csv = False
        self._input_file = ""

        self.setup()
Ejemplo n.º 14
0
    def __init__(self, block, type_to_block_map, **kwds):
        """
        Sets up an editor for a block.
        Input:
            block[BlockInfo]: Block to be edited.
        """
        super(BlockEditor, self).__init__(**kwds)
        self.block = block
        self.comment_edit = CommentEditor()
        self.comment_edit.setComments(self.block.comments)
        self.comment_edit.textChanged.connect(self._blockChanged)
        self.splitter = None
        self.clone_button = None
        self.clone_shortcut = None
        self.remove_button = None
        self.apply_button = None
        self.reset_button = None
        self.new_parameter_button = None
        self.param_editor = None
        self.setWindowTitle(block.path)

        if block.types:
            self.param_editor = ParamsByType(block, type_to_block_map)
        elif block.parameters:
            self.param_editor = ParamsByGroup(block, block.orderedParameters(),
                                              type_to_block_map)
        else:
            self.param_editor = ParamsTable(block, block.orderedParameters(),
                                            type_to_block_map)

        self.param_editor.needBlockList.connect(self.needBlockList)
        self.param_editor.changed.connect(self._blockChanged)
        self.param_editor.blockRenamed.connect(self.blockRenamed)

        self._createButtons()
        self.applyChanges()
        self._current_commands = []
        self._command_index = 0
        self.user_params = []

        self.splitter = QSplitter(self)
        self.splitter.setOrientation(Qt.Vertical)
        self.splitter.setChildrenCollapsible(False)
        self.splitter.addWidget(self.param_editor)
        self.splitter.addWidget(self.comment_edit)
        self.splitter.setStretchFactor(0, 2)
        self.splitter.setStretchFactor(1, 1)
        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.top_layout.addWidget(self.splitter)
        self.top_layout.addLayout(self.button_layout)
        self.setLayout(self.top_layout)

        self.setup()
    def __init__(self, **kwds):
        super(ExecuteSettings, self).__init__(**kwds)

        self.top_layout = WidgetUtils.addLayout(grid=True)
        self.setLayout(self.top_layout)
        tmp, self.max_args_spinbox = self._addOptionToGrid(
            "Max recent working dirs", 0)
        tmp, self.max_exes_spinbox = self._addOptionToGrid(
            "Max recent executables", 1)
        tmp, self.max_working_spinbox = self._addOptionToGrid(
            "Max recent arguments", 2)
        self.setup()
Ejemplo n.º 16
0
 def __init__(self, **kwds):
     """
     Constructor.
     """
     super(LogWidget, self).__init__(**kwds)
     self.top_layout = WidgetUtils.addLayout(vertical=True)
     self.setLayout(self.top_layout)
     self.log = QTextBrowser(self)
     self.log.setStyleSheet(
         "QTextBrowser { background: black; color: white; }")
     self.log.setReadOnly(True)
     message.messageEmitter.message.connect(self._write)
     self.button_layout = WidgetUtils.addLayout()
     self.hide_button = WidgetUtils.addButton(self.button_layout, self,
                                              "Hide", lambda: self.hide())
     self.clear_button = WidgetUtils.addButton(self.button_layout, self,
                                               "Clear",
                                               lambda: self.log.clear())
     self.top_layout.addWidget(self.log)
     self.top_layout.addLayout(self.button_layout)
     self.resize(800, 500)
Ejemplo n.º 17
0
    def __init__(self, **kwds):
        super(InputSettings, self).__init__(**kwds)

        self.top_layout = WidgetUtils.addLayout(grid=True)
        self.setLayout(self.top_layout)
        label = WidgetUtils.addLabel(None, None, "Max recently used")
        spin = QSpinBox()
        spin.setMinimum(1)
        spin.setMaximum(20)
        self.top_layout.addWidget(label, 0, 0)
        self.top_layout.addWidget(spin, 0, 1)
        self.max_recent_spinbox = spin
        self.setup()
Ejemplo n.º 18
0
    def __init__(self, block, type_to_block_map, **kwds):
        """
        Sets up an editor for a block.
        Input:
            block[BlockInfo]: Block to be edited.
        """
        super(BlockEditor, self).__init__(**kwds)
        self.block = block
        self.comment_edit = CommentEditor()
        self.comment_edit.setComments(self.block.comments)
        self.comment_edit.textChanged.connect(self._blockChanged)
        self.splitter = None
        self.clone_button = None
        self.clone_shortcut = None
        self.remove_button = None
        self.apply_button = None
        self.reset_button = None
        self.new_parameter_button = None
        self.param_editor = None
        self.setWindowTitle(block.path)

        if block.types:
            self.param_editor = ParamsByType(block, type_to_block_map)
        elif block.parameters:
            self.param_editor = ParamsByGroup(block, block.orderedParameters(), type_to_block_map)
        else:
            self.param_editor = ParamsTable(block, block.orderedParameters(), type_to_block_map)

        self.param_editor.needBlockList.connect(self.needBlockList)
        self.param_editor.changed.connect(self._blockChanged)
        self.param_editor.blockRenamed.connect(self.blockRenamed)

        self._createButtons()
        self.applyChanges()
        self._current_commands = []
        self._command_index = 0
        self.user_params = []

        self.splitter = QSplitter(self)
        self.splitter.setOrientation(Qt.Vertical)
        self.splitter.setChildrenCollapsible(False)
        self.splitter.addWidget(self.param_editor)
        self.splitter.addWidget(self.comment_edit)
        self.splitter.setStretchFactor(0,2)
        self.splitter.setStretchFactor(1,1)
        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.top_layout.addWidget(self.splitter)
        self.top_layout.addLayout(self.button_layout)
        self.setLayout(self.top_layout)

        self.setup()
Ejemplo n.º 19
0
    def __init__(self, **kwds):
        super(PythonConsoleWidget, self).__init__(**kwds)

        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.setLayout(self.top_layout)
        self.output = QPlainTextEdit(parent=self)
        self.output.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.output.setReadOnly(False)
        self.output.setFocusPolicy(Qt.ClickFocus)
        self.output.setStyleSheet("QPlainTextEdit { background: black; color: white;}")
        self.output.setTextInteractionFlags(Qt.TextSelectableByMouse|Qt.TextSelectableByKeyboard|Qt.LinksAccessibleByMouse|Qt.LinksAccessibleByKeyboard)
        self.top_layout.addWidget(self.output)

        self.input_layout = WidgetUtils.addLayout()
        self.top_layout.addLayout(self.input_layout)
        self.prompt = WidgetUtils.addLabel(self.input_layout, self, ">>>")

        self.input_line = WidgetUtils.addLineEdit(self.input_layout, self, self._returnPressed)
        self.input_line.setFocusPolicy(Qt.StrongFocus)
        self.input_line.installEventFilter(self)

        self.user_inputs = []
        self.current_index = -1
        # get a list of globals and locals from the callstack
        self._global_data = {}
        self._global_data['global_vars'] = globals()
        self._global_data['peacock'] = {}
        self.console = QPythonConsole(self._global_data, parent=self)
        self.console.write_output.connect(self.output.appendPlainText)
        self.output.appendPlainText("Peaock variables are in the dict 'peacock'")
        self.output.appendPlainText("Global variables are in the dict 'global_vars'")
        self.console.prompt_changed.connect(self.prompt.setText)
        self.new_line.connect(self.console._newLine)
        self.console._setPrompt()
        self._loadHistory()
        self.resize(600, 400)
        self.setup()
Ejemplo n.º 20
0
    def __init__(self, **kwds):
        super(InputFileEditor, self).__init__(**kwds)
        self.tree = InputTree(ExecutableInfo())
        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.setLayout(self.top_layout)
        self.block_tree = BlockTree(self.tree)
        self.top_layout.addWidget(self.block_tree)
        self.block_tree.blockClicked.connect(self._blockClicked)
        self.block_tree.blockDoubleClicked.connect(self._blockEditorRequested)
        self.block_tree.changed.connect(lambda block: self.blockChanged.emit(block, self.tree))
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.block_editor = None

        self.setup()
Ejemplo n.º 21
0
 def __init__(self, comments=""):
     """
     Just holds a TextEdit and a label
     """
     super(CommentEditor, self).__init__()
     self.top_layout = WidgetUtils.addLayout(vertical=True)
     self.setLayout(self.top_layout)
     self.editor = QPlainTextEdit(self)
     self.editor.resize(10, 10)
     self.editor.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
     self.editor.setPlainText(comments)
     self.label = WidgetUtils.addLabel(self.top_layout, self, "Comment")
     self.top_layout.addWidget(self.editor)
     self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
     self.setMinimumSize(0, 20)
     self.editor.textChanged.connect(self.textChanged)
Ejemplo n.º 22
0
    def __init__(self, block, type_block_map, **kwds):
        """
        Constructor.
        Input:
            block[BlockInfo]: The block to show.
        """
        super(ParamsByType, self).__init__(**kwds)
        self.block = block
        self.combo = QComboBox()
        self.types = []
        self.type_params_map = {}
        self.type_block_map = type_block_map
        self.table_stack = QStackedWidget()
        self.type_table_map = {}

        for t in sorted(self.block.types.keys()):
            self.types.append(t)
            params_list = []
            for p in self.block.parameters_list:
                params_list.append(self.block.parameters[p])
            t_block = self.block.types[t]
            for p in t_block.parameters_list:
                params_list.append(t_block.parameters[p])
            self.type_params_map[t] = params_list

        self.combo.addItems(sorted(self.block.types.keys()))
        self.combo.currentTextChanged.connect(self.setBlockType)

        self.top_layout = WidgetUtils.addLayout(vertical=True)
        self.top_layout.addWidget(self.combo)
        self.top_layout.addWidget(self.table_stack)
        self.setLayout(self.top_layout)
        self.user_params = []
        self.setDefaultBlockType()

        self.setup()
Ejemplo n.º 23
0
    def __init__(self, **kwds):
        super(ExecuteOptionsPlugin, self).__init__(**kwds)

        self._preferences.addInt("execute/maxRecentWorkingDirs",
                "Max recent working directories",
                10,
                1,
                50,
                "Set the maximum number of recent working directories that have been used.",
                )
        self._preferences.addInt("execute/maxRecentExes",
                "Max recent executables",
                10,
                1,
                50,
                "Set the maximum number of recent executables that have been used.",
                )
        self._preferences.addInt("execute/maxRecentArgs",
                "Max recent command line arguments",
                10,
                1,
                50,
                "Set the maximum number of recent command line arguments that have been used.",
                )
        self._preferences.addBool("execute/mpiEnabled",
                "Enable MPI by default",
                False,
                "Set the MPI checkbox on by default",
                )
        self._preferences.addString("execute/mpiArgs",
                "Default mpi command",
                "mpiexec -n 2",
                "Set the default MPI command to run",
                )
        self._preferences.addBool("execute/threadsEnabled",
                "Enable threads by default",
                False,
                "Set the threads checkbox on by default",
                )
        self._preferences.addString("execute/threadsArgs",
                "Default threads arguments",
                "--n-threads=2",
                "Set the default threads arguments",
                )

        self.all_exe_layout = WidgetUtils.addLayout(grid=True)
        self.setLayout(self.all_exe_layout)

        self.working_label = WidgetUtils.addLabel(None, self, "Working Directory")
        self.all_exe_layout.addWidget(self.working_label, 0, 0)
        self.choose_working_button = WidgetUtils.addButton(None, self, "Choose", self._chooseWorkingDir)
        self.all_exe_layout.addWidget(self.choose_working_button, 0, 1)
        self.working_line = WidgetUtils.addLineEdit(None, self, None, readonly=True)
        self.working_line.setText(os.getcwd())
        self.all_exe_layout.addWidget(self.working_line, 0, 2)

        self.exe_label = WidgetUtils.addLabel(None, self, "Executable")
        self.all_exe_layout.addWidget(self.exe_label, 1, 0)
        self.choose_exe_button = WidgetUtils.addButton(None, self, "Choose", self._chooseExecutable)
        self.all_exe_layout.addWidget(self.choose_exe_button, 1, 1)
        self.exe_line = WidgetUtils.addLineEdit(None, self, None, readonly=True)
        self.all_exe_layout.addWidget(self.exe_line, 1, 2)

        self.args_label = WidgetUtils.addLabel(None, self, "Extra Arguments")
        self.all_exe_layout.addWidget(self.args_label, 2, 0)
        self.args_line = WidgetUtils.addLineEdit(None, self, None)
        self.all_exe_layout.addWidget(self.args_line, 2, 2)

        self.mpi_label = WidgetUtils.addLabel(None, self, "Use MPI")
        self.all_exe_layout.addWidget(self.mpi_label, 3, 0)
        self.mpi_checkbox = WidgetUtils.addCheckbox(None, self, "", None)
        self.mpi_checkbox.setChecked(self._preferences.value("execute/mpiEnabled"))
        self.all_exe_layout.addWidget(self.mpi_checkbox, 3, 1, alignment=Qt.AlignHCenter)
        self.mpi_line = WidgetUtils.addLineEdit(None, self, None)
        self.mpi_line.setText(self._preferences.value("execute/mpiArgs"))
        self.mpi_line.cursorPositionChanged.connect(self._mpiLineCursorChanged)
        self.all_exe_layout.addWidget(self.mpi_line, 3, 2)

        self.threads_label = WidgetUtils.addLabel(None, self, "Use Threads")
        self.all_exe_layout.addWidget(self.threads_label, 4, 0)
        self.threads_checkbox = WidgetUtils.addCheckbox(None, self, "", None)
        self.threads_checkbox.setChecked(self._preferences.value("execute/threadsEnabled"))
        self.all_exe_layout.addWidget(self.threads_checkbox, 4, 1, alignment=Qt.AlignHCenter)
        self.threads_line = WidgetUtils.addLineEdit(None, self, None)
        self.threads_line.setText(self._preferences.value("execute/threadsArgs"))
        self.threads_line.cursorPositionChanged.connect(self._threadsLineCursorChanged)
        self.all_exe_layout.addWidget(self.threads_line, 4, 2)

        self.csv_label = WidgetUtils.addLabel(None, self, "Postprocessor CSV Output")
        self.all_exe_layout.addWidget(self.csv_label, 5, 0)
        self.csv_checkbox = WidgetUtils.addCheckbox(None, self, "", None)
        self.all_exe_layout.addWidget(self.csv_checkbox, 5, 1, alignment=Qt.AlignHCenter)
        self.csv_checkbox.setCheckState(Qt.Checked)

        self.recover_label = WidgetUtils.addLabel(None, self, "Recover")
        self.all_exe_layout.addWidget(self.recover_label, 6, 0)
        self.recover_checkbox = WidgetUtils.addCheckbox(None, self, "", None)
        self.all_exe_layout.addWidget(self.recover_checkbox, 6, 1, alignment=Qt.AlignHCenter)

        self._recent_exe_menu = None
        self._recent_working_menu = None
        self._recent_args_menu = None
        self._exe_watcher = QFileSystemWatcher()
        self._exe_watcher.fileChanged.connect(self.setExecutablePath)

        self._loading_dialog = QMessageBox(parent=self)
        self._loading_dialog.setWindowTitle("Loading executable")
        self._loading_dialog.setStandardButtons(QMessageBox.NoButton) # get rid of the OK button
        self._loading_dialog.setWindowModality(Qt.ApplicationModal)
        self._loading_dialog.setIcon(QMessageBox.Information)
        self._loading_dialog.setText("Loading executable")

        self.setup()
Ejemplo n.º 24
0
    def __init__(self, **kwds):
        super(ExecuteOptionsPlugin, self).__init__(**kwds)

        self._preferences.addInt("execute/maxRecentWorkingDirs",
                "Max recent working directories",
                10,
                1,
                50,
                "Set the maximum number of recent working directories that have been used.",
                )
        self._preferences.addInt("execute/maxRecentExes",
                "Max recent executables",
                10,
                1,
                50,
                "Set the maximum number of recent executables that have been used.",
                )
        self._preferences.addInt("execute/maxRecentArgs",
                "Max recent command line arguments",
                10,
                1,
                50,
                "Set the maximum number of recent command line arguments that have been used.",
                )
        self._preferences.addBool("execute/allowTestObjects",
                "Allow using test objects",
                False,
                "Allow using test objects by default",
                )
        self._preferences.addBool("execute/mpiEnabled",
                "Enable MPI by default",
                False,
                "Set the MPI checkbox on by default",
                )
        self._preferences.addString("execute/mpiArgs",
                "Default mpi command",
                "mpiexec -n 2",
                "Set the default MPI command to run",
                )
        self._preferences.addBool("execute/threadsEnabled",
                "Enable threads by default",
                False,
                "Set the threads checkbox on by default",
                )
        self._preferences.addString("execute/threadsArgs",
                "Default threads arguments",
                "--n-threads=2",
                "Set the default threads arguments",
                )

        self.all_exe_layout = WidgetUtils.addLayout(grid=True)
        self.setLayout(self.all_exe_layout)

        self.working_label = WidgetUtils.addLabel(None, self, "Working Directory")
        self.all_exe_layout.addWidget(self.working_label, 0, 0)
        self.choose_working_button = WidgetUtils.addButton(None, self, "Choose", self._chooseWorkingDir)
        self.all_exe_layout.addWidget(self.choose_working_button, 0, 1)
        self.working_line = WidgetUtils.addLineEdit(None, self, None, readonly=True)
        self.working_line.setText(os.getcwd())
        self.all_exe_layout.addWidget(self.working_line, 0, 2)

        self.exe_label = WidgetUtils.addLabel(None, self, "Executable")
        self.all_exe_layout.addWidget(self.exe_label, 1, 0)
        self.choose_exe_button = WidgetUtils.addButton(None, self, "Choose", self._chooseExecutable)
        self.all_exe_layout.addWidget(self.choose_exe_button, 1, 1)
        self.exe_line = WidgetUtils.addLineEdit(None, self, None, readonly=True)
        self.all_exe_layout.addWidget(self.exe_line, 1, 2)

        self.args_label = WidgetUtils.addLabel(None, self, "Extra Arguments")
        self.all_exe_layout.addWidget(self.args_label, 2, 0)
        self.args_line = WidgetUtils.addLineEdit(None, self, None)
        self.all_exe_layout.addWidget(self.args_line, 2, 2)

        self.test_label = WidgetUtils.addLabel(None, self, "Allow test objects")
        self.all_exe_layout.addWidget(self.test_label, 3, 0)
        self.test_checkbox = WidgetUtils.addCheckbox(None, self, "", self._allowTestObjects)
        self.test_checkbox.setChecked(self._preferences.value("execute/allowTestObjects"))
        self.all_exe_layout.addWidget(self.test_checkbox, 3, 1, alignment=Qt.AlignHCenter)

        self.mpi_label = WidgetUtils.addLabel(None, self, "Use MPI")
        self.all_exe_layout.addWidget(self.mpi_label, 4, 0)
        self.mpi_checkbox = WidgetUtils.addCheckbox(None, self, "", None)
        self.mpi_checkbox.setChecked(self._preferences.value("execute/mpiEnabled"))
        self.all_exe_layout.addWidget(self.mpi_checkbox, 4, 1, alignment=Qt.AlignHCenter)
        self.mpi_line = WidgetUtils.addLineEdit(None, self, None)
        self.mpi_line.setText(self._preferences.value("execute/mpiArgs"))
        self.mpi_line.cursorPositionChanged.connect(self._mpiLineCursorChanged)
        self.all_exe_layout.addWidget(self.mpi_line, 4, 2)

        self.threads_label = WidgetUtils.addLabel(None, self, "Use Threads")
        self.all_exe_layout.addWidget(self.threads_label, 5, 0)
        self.threads_checkbox = WidgetUtils.addCheckbox(None, self, "", None)
        self.threads_checkbox.setChecked(self._preferences.value("execute/threadsEnabled"))
        self.all_exe_layout.addWidget(self.threads_checkbox, 5, 1, alignment=Qt.AlignHCenter)
        self.threads_line = WidgetUtils.addLineEdit(None, self, None)
        self.threads_line.setText(self._preferences.value("execute/threadsArgs"))
        self.threads_line.cursorPositionChanged.connect(self._threadsLineCursorChanged)
        self.all_exe_layout.addWidget(self.threads_line, 5, 2)

        self.csv_label = WidgetUtils.addLabel(None, self, "Postprocessor CSV Output")
        self.all_exe_layout.addWidget(self.csv_label, 6, 0)
        self.csv_checkbox = WidgetUtils.addCheckbox(None, self, "", None)
        self.all_exe_layout.addWidget(self.csv_checkbox, 6, 1, alignment=Qt.AlignHCenter)
        self.csv_checkbox.setCheckState(Qt.Checked)

        self.recover_label = WidgetUtils.addLabel(None, self, "Recover")
        self.all_exe_layout.addWidget(self.recover_label, 7, 0)
        self.recover_checkbox = WidgetUtils.addCheckbox(None, self, "", None)
        self.all_exe_layout.addWidget(self.recover_checkbox, 7, 1, alignment=Qt.AlignHCenter)

        self._recent_exe_menu = None
        self._recent_working_menu = None
        self._recent_args_menu = None
        self._exe_watcher = QFileSystemWatcher()
        self._exe_watcher.fileChanged.connect(self.setExecutablePath)

        self._loading_dialog = QMessageBox(parent=self)
        self._loading_dialog.setWindowTitle("Loading executable")
        self._loading_dialog.setStandardButtons(QMessageBox.NoButton) # get rid of the OK button
        self._loading_dialog.setWindowModality(Qt.ApplicationModal)
        self._loading_dialog.setIcon(QMessageBox.Information)
        self._loading_dialog.setText("Loading executable")

        self.setup()