Пример #1
0
 def _callbackClipDirection(self):
     """
     Callback for when clip direction is altered.
     """
     index = self.ClipDirection.currentIndex()
     WidgetUtils.loadWidget(self.ClipSlider, self.stateKey(index), 'ClipDirection')
     self.clip()
Пример #2
0
 def _callbackClipSlider(self, value):
     """
     Callback for slider.
     """
     index = self.ClipDirection.currentIndex()
     WidgetUtils.storeWidget(self.ClipSlider, self.stateKey(index), 'ClipDirection')
     self.clip()
Пример #3
0
 def _callbackClipSlider(self):
     """
     Callback for slider.
     """
     index = self.ClipDirection.currentIndex()
     WidgetUtils.storeWidget(self.ClipSlider, index, 'ClipDirection')
     self.clip()
Пример #4
0
 def testDump(self):
     objs = [QObject()]
     objs.append(QObject(parent=objs[0]))
     objs.append(QObject(parent=objs[0]))
     objs.append(QObject(parent=objs[1]))
     objs.append(QObject(parent=objs[2]))
     WidgetUtils.dumpQObjectTree(objs[0])
 def testDump(self):
     objs = [QObject()]
     objs.append(QObject(parent=objs[0]))
     objs.append(QObject(parent=objs[0]))
     objs.append(QObject(parent=objs[1]))
     objs.append(QObject(parent=objs[2]))
     WidgetUtils.dumpQObjectTree(objs[0])
Пример #6
0
 def _callbackClipDirection(self):
     """
     Callback for when clip direction is altered.
     """
     index = self.ClipDirection.currentIndex()
     WidgetUtils.loadWidget(self.ClipSlider, index, 'ClipDirection')
     self.clip()
Пример #7
0
 def _callbackClipSlider(self, value):
     """
     Callback for slider.
     """
     index = self.ClipDirection.currentIndex()
     WidgetUtils.storeWidget(self.ClipSlider, self.stateKey(index), 'ClipDirection')
     self.clip()
Пример #8
0
 def _addMenus(self):
     """
     Internal method to allow plugins to add menus to the main menu bar.
     """
     super(PeacockMainWindow, self)._addMenus()
     menubar = self.menuBar()
     debug_menu = menubar.addMenu("Debug")
     WidgetUtils.addAction(debug_menu, "Show Python Console", self._showConsole, "Ctrl+P", True)
Пример #9
0
 def _callbackViewMeshToggle(self):
     """
     Callback for ViewMeshToggle widget. (protected)
     """
     WidgetUtils.storeWidget(self.ViewMeshToggle,
                             self.Representation.currentIndex(),
                             'Respresentation')
     self.mesh()
Пример #10
0
 def _addMenus(self):
     """
     Internal method to allow plugins to add menus to the main menu bar.
     """
     super(PeacockMainWindow, self)._addMenus()
     menubar = self.menuBar()
     debug_menu = menubar.addMenu("Debug")
     WidgetUtils.addAction(debug_menu, "Show Python Console", self._showConsole, "Ctrl+P", True)
 def _callbackComponentList(self):
     """
     Called when the component is selected.
     """
     index = self.ComponentList.currentData()
     self.resultOptionsChanged.emit({'component':index})
     self.store(self._variable, 'Variable')
     WidgetUtils.loadWidget(self.RangeMinimum, index, 'Component')
     WidgetUtils.loadWidget(self.RangeMaximum, index, 'Component')
     self.setLimit(0)
     self.setLimit(1)
     self.windowRequiresUpdate.emit()
Пример #12
0
 def _callbackComponentList(self):
     """
     Called when the component is selected.
     """
     index = self.ComponentList.currentData()
     self.resultOptionsChanged.emit({'component':index})
     self.store(self.stateKey(self._variable), 'Variable')
     WidgetUtils.loadWidget(self.RangeMinimum, self.stateKey(index), 'Component')
     WidgetUtils.loadWidget(self.RangeMaximum, self.stateKey(index), 'Component')
     self.setLimit(0)
     self.setLimit(1)
     self.windowRequiresUpdate.emit()
Пример #13
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()
Пример #14
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()
Пример #15
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")
Пример #16
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")
Пример #17
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()
Пример #18
0
    def _callbackRepresentation(self):
        """
        Callback for Representation widget. (protected)
        """

        WidgetUtils.loadWidget(self.ViewMeshToggle, self.stateKey(self.Representation.currentIndex()), 'Respresentation')

        index = self.Representation.currentIndex()
        if index == 0:
            self.ViewMeshToggle.setEnabled(True)
        else:
            self.ViewMeshToggle.setEnabled(False)
            self.ViewMeshToggle.setChecked(QtCore.Qt.Unchecked)

        self.mesh()
Пример #19
0
    def _callbackRepresentation(self):
        """
        Callback for Representation widget. (protected)
        """

        WidgetUtils.loadWidget(self.ViewMeshToggle, self.stateKey(self.Representation.currentIndex()), 'Respresentation')

        index = self.Representation.currentIndex()
        if index == 0:
            self.ViewMeshToggle.setEnabled(True)
        else:
            self.ViewMeshToggle.setEnabled(False)
            self.ViewMeshToggle.setChecked(QtCore.Qt.Unchecked)

        self.mesh()
Пример #20
0
    def load(self, key, cache, **kwargs):
        """
        Load the state of the widget.

        Args:
            key[str]: The key to which the current settings should be stored.
            cache[str|list]: A list of cache(s) that the values should be stored.

        Kwargs:
            passed to peacock.utils.WidgetUtils.storeWidget
        """
        if not isinstance(cache, list):
            cache = [cache]

        for c in cache:
            WidgetUtils.loadWidget(self, str(key), c, **kwargs)
Пример #21
0
    def __init__(self, tree, **kwds):
        """
        Input:
            tree[InputTree]: The input tree to read blocks from.
        """
        super(BlockTree, self).__init__(**kwds)

        self.tree = tree
        self.root_item = self.invisibleRootItem()
        self.header().close()
        self.setFocusPolicy(Qt.WheelFocus)
        self._item_block_map = {}
        self._path_item_map = {}

        self.setAcceptDrops(True)
        self.setDropIndicatorShown(True)
        self.setDragDropMode(QAbstractItemView.InternalMove)
        self._mime_type = "application/x-qabstractitemmodeldatalist"
        self._current_drag = None

        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._treeContextMenu)
        self.itemClicked.connect(self.onItemClicked)
        self.itemDoubleClicked.connect(self.onItemDoubleClicked)
        self.itemChanged.connect(self.onItemChanged)
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
        self.setExpandsOnDoubleClick(False)
        self.setItemsExpandable(True)
        self.setMouseTracking(False)
        self.setSelectionMode(QAbstractItemView.SingleSelection)

        self.clone_shortcut = WidgetUtils.addShortcut(self, "Ctrl+N", self._newBlockShortcut, shortcut_with_children=True)
        self.populateFromTree()
        self.setup()
Пример #22
0
    def load(self, key, cache, **kwargs):
        """
        Load the state of the widget.

        Args:
            key[str]: The key to which the current settings should be stored.
            cache[str|list]: A list of cache(s) that the values should be stored.

        Kwargs:
            passed to peacock.utils.WidgetUtils.storeWidget
        """
        if not isinstance(cache, list):
            cache = [cache]

        for c in cache:
            WidgetUtils.loadWidget(self, str(key), c, **kwargs)
Пример #23
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()
Пример #24
0
    def addToMenu(self, menu):
        """
        Adds menu entries specific to the Arguments to the menubar.
        """
        workingMenu = menu.addMenu("Recent &working dirs")
        self._recent_working_menu = RecentlyUsedMenu(workingMenu,
                "execute/recentWorkingDirs",
                "execute/maxRecentWorkingDirs",
                20,
                )
        self._recent_working_menu.selected.connect(self.setWorkingDir)
        self._workingDirChanged()

        exeMenu = menu.addMenu("Recent &executables")
        self._recent_exe_menu = RecentlyUsedMenu(exeMenu,
                "execute/recentExes",
                "execute/maxRecentExes",
                20,
                )
        self._recent_exe_menu.selected.connect(self.setExecutablePath)

        argsMenu = menu.addMenu("Recent &arguments")
        self._recent_args_menu = RecentlyUsedMenu(argsMenu,
                "execute/recentArgs",
                "execute/maxRecentArgs",
                20,
                )
        self._recent_args_menu.selected.connect(self._setExecutableArgs)
        self._force_reload_action = WidgetUtils.addAction(menu, "Reload executable syntax", self._reload_syntax)
        self._force_reload_action.setEnabled(False)
Пример #25
0
    def addToMenu(self, menu):
        """
        Adds menu entries specific to the Arguments to the menubar.
        """
        workingMenu = menu.addMenu("Recent &working dirs")
        self._recent_working_menu = RecentlyUsedMenu(
            workingMenu,
            "execute/recentWorkingDirs",
            "execute/maxRecentWorkingDirs",
            20,
        )
        self._recent_working_menu.selected.connect(self.setWorkingDir)
        self._workingDirChanged()

        exeMenu = menu.addMenu("Recent &executables")
        self._recent_exe_menu = RecentlyUsedMenu(
            exeMenu,
            "execute/recentExes",
            "execute/maxRecentExes",
            20,
        )
        self._recent_exe_menu.selected.connect(self.setExecutablePath)

        argsMenu = menu.addMenu("Recent &arguments")
        self._recent_args_menu = RecentlyUsedMenu(
            argsMenu,
            "execute/recentArgs",
            "execute/maxRecentArgs",
            20,
        )
        self._recent_args_menu.selected.connect(self._setExecutableArgs)
        self._force_reload_action = WidgetUtils.addAction(
            menu, "Reload executable syntax", self._reload_syntax)
        self._force_reload_action.setEnabled(False)
Пример #26
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)
Пример #27
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)
Пример #28
0
    def load(self, *args, **kwargs):
        """
        Load the state of the widget.

        Args:
            key[str]: The key to which the current settings should be stored.
            *args[list]: List of widgets to store, if not provided self is used.

        Kwargs:
            passed to peacock.utils.WidgetUtils.storeWidget
        """
        key = kwargs.pop('key', self.stateKey())
        if args:
            for widget in args:
                WidgetUtils.loadWidget(widget, key, **kwargs)
        else:
            WidgetUtils.loadWidget(self, key, **kwargs)
 def _addOptionToGrid(self, name, row):
     label = WidgetUtils.addLabel(None, None, name)
     spin = QSpinBox()
     spin.setMinimum(1)
     spin.setMaximum(20)
     self.top_layout.addWidget(label, row, 0)
     self.top_layout.addWidget(spin, row, 1)
     return label, spin
Пример #30
0
 def _addOptionToGrid(self, name, row):
     label = WidgetUtils.addLabel(None, None, name)
     spin = QSpinBox()
     spin.setMinimum(1)
     spin.setMaximum(20)
     self.top_layout.addWidget(label, row, 0)
     self.top_layout.addWidget(spin, row, 1)
     return label, spin
    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
Пример #32
0
    def load(self, *args, **kwargs):
        """
        Load the state of the widget.

        Args:
            key[str]: The key to which the current settings should be stored.
            *args[list]: List of widgets to store, if not provided self is used.

        Kwargs:
            passed to peacock.utils.WidgetUtils.storeWidget
        """
        key = kwargs.pop('key', self.stateKey())
        if args:
            for widget in args:
                WidgetUtils.loadWidget(widget, key, **kwargs)
        else:
            WidgetUtils.loadWidget(self, key, **kwargs)
    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()
Пример #34
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()
Пример #35
0
    def store(self, *args, **kwargs):
        """
        Store the widget state.

        Args:
            *args[list]: List of widgets to store, if not provided self is used.

        Kwargs:
            passed to peacock.utils.WidgetUtils.storeWidget
        """
        self.blockSignals(True)
        key = kwargs.pop('key', self.stateKey())
        if args:
            for widget in args:
                WidgetUtils.storeWidget(widget, key, **kwargs)
        else:
            WidgetUtils.storeWidget(self, key, **kwargs)
        self.blockSignals(False)
Пример #36
0
    def store(self, *args, **kwargs):
        """
        Store the widget state.

        Args:
            *args[list]: List of widgets to store, if not provided self is used.

        Kwargs:
            passed to peacock.utils.WidgetUtils.storeWidget
        """
        self.blockSignals(True)
        key = kwargs.pop('key', self.stateKey())
        if args:
            for widget in args:
                WidgetUtils.storeWidget(widget, key, **kwargs)
        else:
            WidgetUtils.storeWidget(self, key, **kwargs)
        self.blockSignals(False)
Пример #37
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()
Пример #38
0
 def _setupLiveScriptButton(self, qobject):
     """
     Setup method png image output.
     """
     qobject.clicked.connect(self._callbackLiveScriptButton)
     qobject.setIcon(WidgetUtils.createIcon('script.svg'))
     qobject.setIconSize(self._icon_size)
     qobject.setFixedSize(qobject.iconSize())
     qobject.setToolTip("Show the current python script.")
     qobject.setStyleSheet("QPushButton {border:none}")
Пример #39
0
 def _setupPNGButton(self, qobject):
     """
     Setup method png image output.
     """
     qobject.clicked.connect(self._callbackPNGButton)
     qobject.setIcon(WidgetUtils.createIcon('png.svg'))
     qobject.setIconSize(self._icon_size)
     qobject.setFixedSize(qobject.iconSize())
     qobject.setToolTip("Create a png file of the current figure.")
     qobject.setStyleSheet("QPushButton {border:none}")
Пример #40
0
 def _setupPNGButton(self, qobject):
     """
     Setup method png image output.
     """
     qobject.clicked.connect(self._callbackPNGButton)
     qobject.setIcon(WidgetUtils.createIcon('png.svg'))
     qobject.setIconSize(self._icon_size)
     qobject.setFixedSize(qobject.iconSize())
     qobject.setToolTip("Create a png file of the current figure.")
     qobject.setStyleSheet("QPushButton {border:none}")
Пример #41
0
 def _setupLiveTableButton(self, qobject):
     """
     Setup method for python script output button.
     """
     qobject.clicked.connect(self._callbackLiveTableButton)
     qobject.setIcon(WidgetUtils.createIcon('table.svg'))
     qobject.setIconSize(self._icon_size)
     qobject.setFixedSize(qobject.iconSize())
     qobject.setToolTip("Show a table of the CSV data for each open file.")
     qobject.setStyleSheet("QPushButton {border:none}")
Пример #42
0
    def __init__(self):
        super(ViewerCornerWidget, self).__init__()

        self._icon_size = QtCore.QSize(24, 24)

        self.MainLayout = QtWidgets.QHBoxLayout()
        self.MainLayout.setContentsMargins(0, 0, 0, 0)
        self.MainLayout.setSpacing(10)
        self.setLayout(self.MainLayout)

        self.CloseButton = QtWidgets.QPushButton(WidgetUtils.createIcon('close.ico'), 'Close')
        self.CloneButton = QtWidgets.QPushButton(WidgetUtils.createIcon('copy.ico'), 'Clone')

        #self.MainLayout.addStretch()
        self.MainLayout.addWidget(self.CloneButton)
        self.MainLayout.addWidget(self.CloseButton)

        self.setup()
        self.adjustSize()
Пример #43
0
 def __addButton(self, name, tooltip, icon):
     qobject = QtWidgets.QPushButton(self)
     qobject.setToolTip(tooltip)
     qobject.clicked.connect(getattr(self, '_callback' + name))
     qobject.setIcon(WidgetUtils.createIcon(icon))
     qobject.setIconSize(self._icon_size)
     qobject.setFixedSize(qobject.iconSize())
     qobject.setStyleSheet("QPushButton {border:none}")
     self.ButtonLayout.addWidget(qobject)
     setattr(self, name, qobject)
Пример #44
0
 def _setupPythonButton(self, qobject):
     """
     Setup method for python script output button.
     """
     qobject.clicked.connect(self._callbackPythonButton)
     qobject.setIcon(WidgetUtils.createIcon('py.svg'))
     qobject.setIconSize(self._icon_size)
     qobject.setFixedSize(qobject.iconSize())
     qobject.setToolTip("Create python script to reproduce this figure.")
     qobject.setStyleSheet("QPushButton {border:none}")
Пример #45
0
    def __init__(self, plugins):
        super(TabbedPreferences, self).__init__()
        self._widgets = []
        self.layout = QtWidgets.QVBoxLayout()
        self.setLayout(self.layout)
        self.tabs = QtWidgets.QTabWidget(parent=self)
        self.layout.addWidget(self.tabs)
        self.button_layout = QtWidgets.QHBoxLayout()
        self.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)

        for plugin in plugins:
            w = plugin.preferencesWidget()
            if w.count() > 0:
                self._widgets.append(w)
                self.tabs.addTab(w, plugin.tabName())
    def _callbackHideButton(self):
        """
        Toggles the collapsible content.
        """
        self._collapsed = not self._collapsed
        self._collapsible_widget.setHidden(self._collapsed)
#        PeacockCollapsibleWidget.toggleCollapsed(self._collapsible_layout, self._collapsed)

        name = 'plus.svg' if self._collapsed else 'minus.svg'
        self._collapse_button.setIcon(WidgetUtils.createIcon(name))
Пример #47
0
 def _setupPythonButton(self, qobject):
     """
     Setup method for python script output button.
     """
     qobject.clicked.connect(self._callbackPythonButton)
     qobject.setIcon(WidgetUtils.createIcon('py.svg'))
     qobject.setIconSize(self._icon_size)
     qobject.setFixedSize(qobject.iconSize())
     qobject.setToolTip("Create python script to reproduce this figure.")
     qobject.setStyleSheet("QPushButton {border:none}")
Пример #48
0
 def _setupLiveScriptButton(self, qobject):
     """
     Setup method png image output.
     """
     qobject.clicked.connect(self._callbackLiveScriptButton)
     qobject.setIcon(WidgetUtils.createIcon('script.svg'))
     qobject.setIconSize(self._icon_size)
     qobject.setFixedSize(qobject.iconSize())
     qobject.setToolTip("Show the current python script.")
     qobject.setStyleSheet("QPushButton {border:none}")
Пример #49
0
 def __addButton(self, name, tooltip, icon):
     qobject = QtWidgets.QPushButton(self)
     qobject.setToolTip(tooltip)
     qobject.clicked.connect(getattr(self, '_callback' + name))
     qobject.setIcon(WidgetUtils.createIcon(icon))
     qobject.setIconSize(self._icon_size)
     qobject.setFixedSize(qobject.iconSize())
     qobject.setStyleSheet("QPushButton {border:none}")
     self.ButtonLayout.addWidget(qobject)
     setattr(self, name, qobject)
Пример #50
0
 def _setupLiveTableButton(self, qobject):
     """
     Setup method for python script output button.
     """
     qobject.clicked.connect(self._callbackLiveTableButton)
     qobject.setIcon(WidgetUtils.createIcon('table.svg'))
     qobject.setIconSize(self._icon_size)
     qobject.setFixedSize(qobject.iconSize())
     qobject.setToolTip("Show a table of the CSV data for each open file.")
     qobject.setStyleSheet("QPushButton {border:none}")
    def setLimit(self, index, emit=True):
        """
        Callback for min/max editing. This controls the auto flags that allow for the compute limits to display.

        Args:
            qobject[QWidget]: The object being adjusted
        """
        # Determine the object
        qobject = [self.RangeMinimum, self.RangeMaximum][index]
        key = ['min', 'max'][index]
        component = self.ComponentList.currentData()

        # Do nothing if the object is being editted
        if qobject.hasFocus():
            return

        # Extract the text in the edit box
        text = qobject.text()

        if self._result:
            # Empty: Display the limits in grey
            if (text == '' ) or (self._auto[index] == True):

                #@TODO: This update call should not be needed, but somewhere the result is getting out-of-date
                if self._result.needsUpdate():
                    self._result.update()
                lim = self._result.getRange()
                self.resultOptionsChanged.emit({key:lim[index]})
                qobject.setText(str(lim[index]))
                qobject.setStyleSheet('color:#8C8C8C')
                self._auto[index] = True
            else:
                try:
                    self.resultOptionsChanged.emit({key:float(text)})
                    self._auto[index] = False
                except:
                    qobject.setStyleSheet('color:#ff0000')

        self.store(self._filename, 'Filename')
        WidgetUtils.storeWidget(qobject, component, 'Component')
        if emit:
            self.windowRequiresUpdate.emit()
Пример #52
0
    def setLimit(self, index, emit=True):
        """
        Callback for min/max editing. This controls the auto flags that allow for the compute limits to display.

        Args:
            qobject[QWidget]: The object being adjusted
        """
        # Determine the object
        qobject = [self.RangeMinimum, self.RangeMaximum][index]
        key = ['min', 'max'][index]
        component = self.ComponentList.currentData()

        # Do nothing if the object is being editted
        if qobject.hasFocus():
            return

        # Extract the text in the edit box
        text = qobject.text()

        if self._result:
            # Empty: Display the limits in grey
            if (text == '' ) or (self._auto[index] == True):

                #@TODO: This update call should not be needed, but somewhere the result is getting out-of-date
                if self._result.needsUpdate():
                    self._result.update()
                lim = self._result.getRange()
                self.resultOptionsChanged.emit({key:lim[index]})
                qobject.setText(str(lim[index]))
                qobject.setStyleSheet('color:#8C8C8C')
                self._auto[index] = True
            else:
                try:
                    self.resultOptionsChanged.emit({key:float(text)})
                    self._auto[index] = False
                except:
                    qobject.setStyleSheet('color:#ff0000')

        WidgetUtils.storeWidget(qobject, self.stateKey(component), 'Component')
        if emit:
            self.windowRequiresUpdate.emit()
Пример #53
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)
Пример #54
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()
Пример #55
0
    def _setupClipSlider(self, qobject):
        """
        Setup method for clip origin selection.
        """
        qobject.setOrientation(QtCore.Qt.Horizontal)
        qobject.setRange(0, self._increments)
        qobject.setSliderPosition(self._increments/2)
        qobject.setProperty('cache', ['ClipDirection'])
        qobject.valueChanged.connect(self._callbackClipSlider)

        # Store the initial state of the slide for index 0, why?
        #
        # Perform the following:
        #   (1) Clipping enabled
        #   (2) Change the axis to 'y'
        #   (3) Move the slider
        #   (4) Change the axis back to 'x'
        #
        # Without this 'x' would be at the 'y' position instead of at the midpoint.
        qobject.setEnabled(True)
        WidgetUtils.storeWidget(qobject, self.stateKey(0), 'ClipDirection')
        qobject.setEnabled(False)
Пример #56
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()