예제 #1
0
 def __init__(self, title):
     super().__init__()
     self.setWindowTitle(title)
     self.lib_path = ""
     self.final_title = ""
     analysis_icon = QIcon(os.path.join(icons_dir, "icon.png"))
     stack_icon = QIcon(os.path.join(icons_dir, "icon_stack.png"))
     self.analysis_button = QToolButton(self)
     self.analysis_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
     self.analysis_button.setIcon(analysis_icon)
     # TODO use more general solution for text wrapping
     self.analysis_button.setText(SEGMENTATION_NAME.replace(" ", "\n"))
     self.analysis_button.setIconSize(QSize(100, 100))
     self.mask_button = QToolButton(self)
     self.mask_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
     self.mask_button.setIcon(stack_icon)
     self.mask_button.setText(MASK_NAME.replace(" ", "\n"))
     self.mask_button.setIconSize(QSize(100, 100))
     self.analysis_button.clicked.connect(self.launch_analysis)
     self.mask_button.clicked.connect(self.launch_mask)
     self.progress = QProgressBar()
     self.progress.setHidden(True)
     layout = QGridLayout()
     layout.addWidget(self.progress, 0, 0, 1, 2)
     layout.addWidget(self.analysis_button, 1, 1)
     layout.addWidget(self.mask_button, 1, 0)
     widget = QWidget()
     widget.setLayout(layout)
     self.setCentralWidget(widget)
     self.setWindowIcon(analysis_icon)
     self.prepare = None
     self.wind = None
예제 #2
0
    def __init__(self, window, app_manager, parent=None):
        QWidget.__init__(self, parent)

        self.app = app_manager
        self._window = window
        self.vboxWindow = QVBoxLayout(self)
        self.windowFrame = QWidget(self)
        self.vboxFrame = QVBoxLayout(self.windowFrame)
        self.titleBar = WindowDragger(self, self.windowFrame)
        self.hboxTitle = QHBoxLayout(self.titleBar)
        self.lblTitle = QLabel('Title')
        self.btnMinimize = QToolButton(self.titleBar)
        self.btnRestore = QToolButton(self.titleBar)
        self.btnMaximize = QToolButton(self.titleBar)
        self.btnClose = QToolButton(self.titleBar)
        self.windowContent = QWidget(self.windowFrame)

        self.setup_ui()

        content_layout = QHBoxLayout()
        content_layout.setContentsMargins(0, 0, 0, 0)
        content_layout.addWidget(window)

        self.windowContent.setLayout(content_layout)

        self.setWindowTitle(window.windowTitle())
        self.setGeometry(window.geometry())

        self.installEventFilter(self)

        # Adding attribute to clean up the parent window when the child is closed
        self._window.setAttribute(Qt.WA_DeleteOnClose, True)
        self._window.destroyed.connect(self.__child_was_closed)
예제 #3
0
파일: caselist.py 프로젝트: oyvindeide/ert
    def __init__(self,
                 addFunction=None,
                 removeFunction=None,
                 horizontal=False):
        QWidget.__init__(self)

        self.addButton = QToolButton(self)
        self.addButton.setIcon(resourceIcon("add_circle_outlined.svg"))
        self.addButton.setIconSize(QSize(16, 16))
        self.addButton.clicked.connect(addFunction)

        self.removeButton = QToolButton(self)
        self.removeButton.setIcon(resourceIcon("remove_outlined.svg"))
        self.removeButton.setIconSize(QSize(16, 16))
        self.removeButton.clicked.connect(removeFunction)

        if horizontal:
            self.buttonLayout = QHBoxLayout()
        else:
            self.buttonLayout = QVBoxLayout()

        self.buttonLayout.setContentsMargins(0, 0, 0, 0)

        if horizontal:
            self.buttonLayout.addStretch(1)

        self.buttonLayout.addWidget(self.addButton)
        self.buttonLayout.addWidget(self.removeButton)

        if not horizontal:
            self.buttonLayout.addStretch(1)
        else:
            self.buttonLayout.addSpacing(2)

        self.setLayout(self.buttonLayout)
예제 #4
0
    def createTimeStepRow(self):
        history_length_spinner = QSpinBox()
        addHelpToWidget(history_length_spinner, "config/init/history_length")
        history_length_spinner.setMinimum(0)
        history_length_spinner.setMaximum(getHistoryLength())

        initial = QToolButton()
        initial.setText("Initial")
        addHelpToWidget(initial, "config/init/history_length")

        def setToMin():
            history_length_spinner.setValue(0)

        initial.clicked.connect(setToMin)

        end_of_time = QToolButton()
        end_of_time.setText("End of time")
        addHelpToWidget(end_of_time, "config/init/history_length")

        def setToMax():
            history_length_spinner.setValue(getHistoryLength())

        end_of_time.clicked.connect(setToMax)

        row = createRow(QLabel("Timestep:"), history_length_spinner, initial,
                        end_of_time)

        return row, history_length_spinner
예제 #5
0
    def __init__(self, *args):
        super(PlotToolBar, self).__init__(*args)
        # Disable moving
        self.setMovable(False)

        # Window menu
        self.window_menu = QMenu()
        self.atn_change_top_axis = self.window_menu.addAction(
            "Change Top Axis")
        self.atn_change_units = self.window_menu.addAction("Change Units")
        self.atn_line_ids = self.window_menu.addAction("Plot Line IDs")

        icon = QIcon(QPixmap(":/img/Settings-50.png"))
        self.window_menu_btn = QToolButton(self)
        self.window_menu_btn.setIcon(icon)
        self.window_menu_btn.setMenu(self.window_menu)
        self.window_menu_btn.setPopupMode(QToolButton.InstantPopup)

        self.addWidget(self.window_menu_btn)

        # Layer menu
        self.layer_menu = QMenu()
        # self.layer_menu.addAction("Color")

        icon = QIcon(QPixmap(":/img/Settings 3-50.png"))
        self.layer_menu_btn = QToolButton(self)
        self.layer_menu_btn.setIcon(icon)
        self.layer_menu_btn.setMenu(self.layer_menu)
        self.layer_menu_btn.setPopupMode(QToolButton.InstantPopup)

        self.addWidget(self.layer_menu_btn)
예제 #6
0
    def __init__(self, name: str, label: list, removable, parent=None):
        super().__init__(parent)
        self.label = label
        self.name = name
        self.removable = removable

        self.radio_btn = QRadioButton()

        self.label_show = _LabelShow(np.array(label, dtype=np.uint8))

        self.remove_btn = QToolButton()
        self.remove_btn.setIcon(_icon_selector.close_icon)

        self.edit_btn = QToolButton()
        self.edit_btn.setIcon(_icon_selector.edit_icon)

        if removable:
            self.remove_btn.setToolTip("Remove colormap")
        else:
            self.remove_btn.setToolTip("This colormap is protected")

        self.edit_btn.setToolTip("Create new label schema base on this")

        layout = QHBoxLayout()
        layout.addWidget(self.radio_btn)
        layout.addWidget(self.label_show, 1)
        layout.addWidget(self.remove_btn)
        layout.addWidget(self.edit_btn)
        self.remove_btn.setEnabled(removable)
        self.setLayout(layout)
        self.remove_btn.clicked.connect(self.remove_fun)
        self.edit_btn.clicked.connect(self.edit_fun)
        self.radio_btn.clicked.connect(self.selected_fun)
예제 #7
0
    def create_buttons(self):
        '''
        Creates the title bar close and menu buttons
        '''
        self.tabs_menu_button = QToolButton()
        self.tabs_menu_button.setObjectName("tabsMenuButton")
        self.tabs_menu_button.setAutoRaise(True)
        self.tabs_menu_button.setPopupMode(QToolButton.InstantPopup)

        style = self.public.style()
        set_button_icon(style, self.tabs_menu_button, QStyle.SP_TitleBarUnshadeButton)

        self.tabs_menu = QMenu(self.tabs_menu_button)
        self.tabs_menu.setToolTipsVisible(True)
        self.tabs_menu.aboutToShow.connect(
            self.public.on_tabs_menu_about_to_show)
        self.tabs_menu_button.setMenu(self.tabs_menu)
        self.tabs_menu_button.setToolTip("List all tabs")

        self.tabs_menu_button.setSizePolicy(
            QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.top_layout.addWidget(self.tabs_menu_button, 0)
        self.tabs_menu_button.menu().triggered.connect(
            self.public.on_tabs_menu_action_triggered)

        # Undock button
        self.undock_button = QToolButton()
        self.undock_button.setObjectName("undockButton")
        self.undock_button.setAutoRaise(True)
        self.undock_button.setToolTip("Detach Group")

        set_button_icon(style, self.undock_button,
                        QStyle.SP_TitleBarNormalButton)

        self.undock_button.setSizePolicy(
            QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.top_layout.addWidget(self.undock_button, 0)
        self.undock_button.clicked.connect(
            self.public.on_undock_button_clicked)

        # Close button
        self.close_button = QToolButton()
        self.close_button.setObjectName("closeButton")
        self.close_button.setAutoRaise(True)

        set_button_icon(style, self.close_button, QStyle.SP_TitleBarCloseButton)

        if self.test_config_flag(DockFlags.dock_area_close_button_closes_tab):
            self.close_button.setToolTip("Close Active Tab")
        else:
            self.close_button.setToolTip("Close Group")

        self.close_button.setSizePolicy(
            QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.close_button.setIconSize(QSize(16, 16))
        self.top_layout.addWidget(self.close_button, 0)
        self.close_button.clicked.connect(self.public.on_close_button_clicked)
예제 #8
0
파일: checklist.py 프로젝트: oyvindeide/ert
 def _createCheckButtons(self):
     self._checkAllButton = QToolButton()
     self._checkAllButton.setIcon(resourceIcon("check.svg"))
     self._checkAllButton.setIconSize(QSize(16, 16))
     self._checkAllButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
     self._checkAllButton.setAutoRaise(True)
     self._checkAllButton.setToolTip("Select all")
     self._uncheckAllButton = QToolButton()
     self._uncheckAllButton.setIcon(resourceIcon("checkbox_outline.svg"))
     self._uncheckAllButton.setIconSize(QSize(16, 16))
     self._uncheckAllButton.setToolButtonStyle(Qt.ToolButtonIconOnly)
     self._uncheckAllButton.setAutoRaise(True)
     self._uncheckAllButton.setToolTip("Unselect all")
예제 #9
0
 def __init__(self, parent, expected_ops, actual_ops):
     super(SyncDetailsDialog, self).__init__(parent)
     self.setupUi(self)
     for idx, actual_op in enumerate(actual_ops):
         actual = actual_ops[idx]
         expected = expected_ops[idx]
         path = QLineEdit(self.scrollAreaWidgetContents)
         path.setReadOnly(True)
         path.setEnabled(False)
         path.setText(actual['path'])
         requested = QLineEdit(self.scrollAreaWidgetContents)
         requested.setReadOnly(True)
         path.setEnabled(False)
         requested.setText(str(expected['value']))
         actual_text = QLineEdit(self.scrollAreaWidgetContents)
         actual_text.setReadOnly(True)
         path.setEnabled(False)
         actual_text.setText(str(actual['value']))
         status = QToolButton(self)
         if actual['op'] != expected['op'] or actual['path'] != expected['path'] or actual['value'] != expected['value']:
             status.setIcon(qta.icon('fa5s.times', color='red'))
         else:
             status.setIcon(qta.icon('fa5s.check', color='green'))
         self.gridLayout_2.addWidget(path, idx+1, 0, 1, 1)
         self.gridLayout_2.addWidget(requested, idx+1, 1, 1, 1)
         self.gridLayout_2.addWidget(actual_text, idx+1, 2, 1, 1)
         self.gridLayout_2.addWidget(status, idx+1, 3, 1, 1)
예제 #10
0
    def addCaseSelector(self, disabled=False):
        widget = QWidget()

        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        widget.setLayout(layout)

        combo = QComboBox()
        combo.setSizeAdjustPolicy(
            QComboBox.AdjustToMinimumContentsLengthWithIcon)
        combo.setMinimumContentsLength(20)
        combo.setModel(self.__model)

        combo.currentIndexChanged.connect(self.caseSelectionChanged.emit)

        layout.addWidget(combo, 1)

        button = QToolButton()
        button.setAutoRaise(True)
        button.setDisabled(disabled)
        button.setIcon(resourceIcon("delete_to_trash.svg"))
        button.clicked.connect(self.__signal_mapper.map)

        layout.addWidget(button)

        self.__case_selectors[widget] = combo
        self.__case_selectors_order.append(widget)
        self.__signal_mapper.setMapping(button, widget)

        self.__case_layout.addWidget(widget)

        self.checkCaseCount()
        self.caseSelectionChanged.emit()
예제 #11
0
    def __init__(
        self,
        facade: LibresFacade,
        module_name: Literal["IES_ENKF", "STD_ENKF"] = "STD_ENKF",
        help_link: str = "",
    ):
        self.facade = facade
        QWidget.__init__(self)

        addHelpToWidget(self, help_link)

        layout = QHBoxLayout()
        self._name = module_name
        analysis_module_label = QLabel(self._name)

        variables_popup_button = QToolButton()
        variables_popup_button.setIcon(resourceIcon("edit.svg"))
        variables_popup_button.clicked.connect(self.showVariablesPopup)
        variables_popup_button.setMaximumSize(20, 20)

        layout.addWidget(analysis_module_label, 0, Qt.AlignLeft)
        layout.addWidget(variables_popup_button, 0, Qt.AlignLeft)
        layout.setContentsMargins(QMargins(0, 0, 0, 0))
        layout.addStretch()

        self.setLayout(layout)
예제 #12
0
    def __init__(self, key_defs):
        QWidget.__init__(self)

        self.__filter_popup = FilterPopup(self, key_defs)
        self.__filter_popup.filterSettingsChanged.connect(self.onItemChanged)

        layout = QVBoxLayout()

        self.model = DataTypeKeysListModel(key_defs)
        self.filter_model = DataTypeProxyModel(self, self.model)

        filter_layout = QHBoxLayout()

        self.search_box = SearchBox()
        self.search_box.filterChanged.connect(self.setSearchString)
        filter_layout.addWidget(self.search_box)

        filter_popup_button = QToolButton()
        filter_popup_button.setIcon(resourceIcon("ide/cog_edit.png"))
        filter_popup_button.clicked.connect(self.showFilterPopup)
        filter_layout.addWidget(filter_popup_button)
        layout.addLayout(filter_layout)

        self.data_type_keys_widget = QListView()
        self.data_type_keys_widget.setModel(self.filter_model)
        self.data_type_keys_widget.selectionModel().selectionChanged.connect(self.itemSelected)

        layout.addSpacing(15)
        layout.addWidget(self.data_type_keys_widget, 2)
        layout.addStretch()

        # layout.addWidget(Legend("Default types", DataTypeKeysListModel.DEFAULT_DATA_TYPE))
        layout.addWidget(Legend("Observations available", DataTypeKeysListModel.HAS_OBSERVATIONS))

        self.setLayout(layout)
예제 #13
0
파일: plugin.py 프로젝트: TTorpin/specviz
    def add_tool_bar_actions(self, icon_path, name="", category=None,
                             description="", priority=0, enabled=True,
                             callback=None, menu=None):
        icon = QIcon(icon_path)

        if menu is not None:
            tool_button = QToolButton()
            tool_button.setPopupMode(QToolButton.MenuButtonPopup)

            menu_widget = self._dict_to_menu(menu)

            tool_button.setMenu(menu_widget)
            tool_button.setIcon(icon)
            tool_button.setText(name)
            tool_button.setStatusTip(description)
            tool_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

            item = QWidgetAction(self)
            item.setDefaultWidget(tool_button)
            item.setEnabled(enabled)
        else:
            item = QAction(self)
            item.triggered.connect(callback if callback is not None else
                                     lambda: None)
            item.setIcon(icon)
            item.setStatusTip(description)
            item.setEnabled(enabled)
            item.setText(name)

        self._actions.append(dict(action=item,
                                  category=(category, 0) if not isinstance(
                                      category, tuple) else category,
                                  priority=priority))

        return item
예제 #14
0
    def __init__(self, possible_items):
        QWidget.__init__(self)

        self._editing = True
        self._possible_items = possible_items

        self._list_edit_line = AutoCompleteLineEdit(possible_items, self)
        self._list_edit_line.setMinimumWidth(350)

        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self._list_edit_line)

        dialog_button = QToolButton(self)
        dialog_button.setIcon(resourceIcon("add_circle_outlined.svg"))
        dialog_button.setIconSize(QSize(16, 16))
        dialog_button.clicked.connect(self.addChoice)

        layout.addWidget(dialog_button)

        self.setLayout(layout)

        self._validation_support = ValidationSupport(self)
        self._valid_color = self._list_edit_line.palette().color(
            self._list_edit_line.backgroundRole())

        self._list_edit_line.setText("")
        self._editing = False

        self._list_edit_line.editingFinished.connect(self.validateList)
        self._list_edit_line.textChanged.connect(self.validateList)

        self.validateList()
    def __init__(self, parent=None, icon=True):
        super(SearchLineEdit, self).__init__(parent)
        self.setTextMargins(1, 0, 20, 0)

        if icon:
            self.setTextMargins(18, 0, 20, 0)
            self._label = QLabel(self)
            self._pixmap_icon = QPixmap(get_image_path('conda_search.png'))
            self._label.setPixmap(self._pixmap_icon)
            self._label.setStyleSheet('''border: 0px; padding-bottom: 0px;
                                      padding-left: 2px;''')

        self._pixmap = QPixmap(get_image_path('conda_del.png'))
        self.button_clear = QToolButton(self)
        self.button_clear.setIcon(QIcon(self._pixmap))
        self.button_clear.setIconSize(QSize(18, 18))
        self.button_clear.setCursor(Qt.ArrowCursor)
        self.button_clear.setStyleSheet("""QToolButton
            {background: transparent;
            padding-right: 2px; border: none; margin:0px; }""")
        self.button_clear.setVisible(False)

        # Layout
        self._layout = QHBoxLayout(self)
        self._layout.addWidget(self.button_clear, 0, Qt.AlignRight)
        self._layout.setSpacing(0)
        self._layout.setContentsMargins(0, 2, 2, 0)

        # Signals and slots
        self.button_clear.clicked.connect(self.clear_text)
        self.textChanged.connect(self._toggle_visibility)
        self.textEdited.connect(self._toggle_visibility)
예제 #16
0
파일: _qt.py 프로젝트: mh105/mne-python
    def _dock_add_button(self,
                         name,
                         callback,
                         *,
                         style='pushbutton',
                         icon=None,
                         tooltip=None,
                         layout=None):
        _check_option(parameter='style',
                      value=style,
                      allowed_values=('toolbutton', 'pushbutton'))
        if style == 'toolbutton':
            widget = QToolButton()
            widget.setText(name)
        else:
            widget = QPushButton(name)
            # Don't change text color upon button press
            widget.setStyleSheet('QPushButton:pressed {color: none;}')
        if icon is not None:
            widget.setIcon(self._icons[icon])

        _set_widget_tooltip(widget, tooltip)
        widget.clicked.connect(callback)

        layout = self._dock_layout if layout is None else layout
        self._layout_add_widget(layout, widget)
        return _QtWidget(widget)
예제 #17
0
    def setAlgorithms(self, algorithms, extensions, tooltips):
        """
        Set the algorithms displayed on the dialog.

        Args:
            algorithms (list(str)): list of algorithms
            extensions (dict(str:str)): extension used by each algorithm
            tooltips (dict(str:str)): short doc of each algorithm
        """
        for i in range(len(algorithms)):
            algo = algorithms[i]
            if algo in extensions:
                text = algo + " (" + extensions[algo] + ")"
            else:
                text = algo
            widget = QCheckBox(text, self)
            if algo in tooltips:
                widget.setToolTip(tooltips[algo])
            self._widgets[algorithms[i]] = widget
            self.algoList.addWidget(widget, i, 0, Qt.AlignLeft)
            helpButton = QToolButton(self)
            helpButton.setText('...')
            helpButton.setIcon(icons.get_icon("mdi.help"))
            helpButton.clicked.connect(
                lambda _, a=algorithms[i]: InterfaceManager().showHelpPage(
                    "qthelp://org.mantidproject/doc/algorithms/{}.html".format(
                        a)))
            self.algoList.addWidget(helpButton, i, 1, Qt.AlignRight)
예제 #18
0
    def __init__(self, parent=None) -> None:
        super().__init__(parent=parent)
        self.setLayout(QHBoxLayout())

        self._activityBtn = QToolButton()
        self._activityBtn.setObjectName("QtActivityButton")
        self._activityBtn.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self._activityBtn.setArrowType(Qt.UpArrow)
        self._activityBtn.setIconSize(QSize(11, 11))
        self._activityBtn.setText(trans._('activity'))
        self._activityBtn.setCheckable(True)

        self._inProgressIndicator = QLabel(trans._("in progress..."), self)
        sp = self._inProgressIndicator.sizePolicy()
        sp.setRetainSizeWhenHidden(True)
        self._inProgressIndicator.setSizePolicy(sp)
        load_gif = str(Path(napari.resources.__file__).parent / "loading.gif")
        mov = QMovie(load_gif)
        mov.setScaledSize(QSize(18, 18))
        self._inProgressIndicator.setMovie(mov)
        self._inProgressIndicator.hide()

        self.layout().addWidget(self._inProgressIndicator)
        self.layout().addWidget(self._activityBtn)
        self.layout().setContentsMargins(0, 0, 0, 0)
예제 #19
0
    def __init__(self, ert: EnKFMain, notifier: ErtNotifier, config_file: str):
        self.notifier = notifier
        QWidget.__init__(self)
        self.ert = ert
        self.facade = LibresFacade(ert)
        self._config_file = config_file

        self.setObjectName("Simulation_panel")
        layout = QVBoxLayout()

        self._simulation_mode_combo = QComboBox()
        self._simulation_mode_combo.setObjectName("Simulation_mode")
        addHelpToWidget(self._simulation_mode_combo, "run/simulation_mode")

        self._simulation_mode_combo.currentIndexChanged.connect(
            self.toggleSimulationMode)

        simulation_mode_layout = QHBoxLayout()
        simulation_mode_layout.addSpacing(10)
        simulation_mode_layout.addWidget(QLabel("Simulation mode:"), 0,
                                         Qt.AlignVCenter)
        simulation_mode_layout.addWidget(self._simulation_mode_combo, 0,
                                         Qt.AlignVCenter)

        simulation_mode_layout.addSpacing(20)

        self.run_button = QToolButton()
        self.run_button.setObjectName("start_simulation")
        self.run_button.setText("Start simulation")
        self.run_button.setIcon(resourceIcon("play_circle.svg"))
        self.run_button.setIconSize(QSize(32, 32))
        self.run_button.clicked.connect(self.runSimulation)
        self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        addHelpToWidget(self.run_button, "run/start_simulation")

        simulation_mode_layout.addWidget(self.run_button)
        simulation_mode_layout.addStretch(1)

        layout.addSpacing(5)
        layout.addLayout(simulation_mode_layout)
        layout.addSpacing(10)

        self._simulation_stack = QStackedWidget()
        self._simulation_stack.setLineWidth(1)
        self._simulation_stack.setFrameStyle(QFrame.StyledPanel)

        layout.addWidget(self._simulation_stack)

        self._simulation_widgets = OrderedDict()
        """ :type: OrderedDict[BaseRunModel,SimulationConfigPanel]"""
        self.addSimulationConfigPanel(SingleTestRunPanel(ert, notifier))
        self.addSimulationConfigPanel(EnsembleExperimentPanel(ert, notifier))
        if self.facade.have_observations:
            self.addSimulationConfigPanel(EnsembleSmootherPanel(ert, notifier))
            self.addSimulationConfigPanel(
                MultipleDataAssimilationPanel(self.facade, notifier))
            self.addSimulationConfigPanel(
                IteratedEnsembleSmootherPanel(self.facade, notifier))

        self.setLayout(layout)
예제 #20
0
def create_toolbutton(parent,
                      text=None,
                      shortcut=None,
                      icon=None,
                      tip=None,
                      toggled=None,
                      triggered=None,
                      autoraise=True,
                      text_beside_icon=False):
    """Create a QToolButton"""
    button = QToolButton(parent)
    if text is not None:
        button.setText(text)
    if icon is not None:
        if is_text_string(icon):
            icon = get_icon(icon)
        button.setIcon(icon)
    if text is not None or tip is not None:
        button.setToolTip(text if tip is None else tip)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    button.setAutoRaise(autoraise)
    if triggered is not None:
        button.clicked.connect(triggered)
    if toggled is not None:
        button.toggled.connect(toggled)
        button.setCheckable(True)
    if shortcut is not None:
        button.setShortcut(shortcut)
    return button
예제 #21
0
    def __init__(self):
        QWidget.__init__(self)
        self._line_edit = ClearableLineEdit()

        self._calendar_button = QToolButton()
        self._calendar_button.setPopupMode(QToolButton.InstantPopup)
        self._calendar_button.setFixedSize(26, 26)
        self._calendar_button.setAutoRaise(True)
        self._calendar_button.setIcon(resourceIcon("calendar_date_range.svg"))
        self._calendar_button.setStyleSheet(
            "QToolButton::menu-indicator { image: none; }")

        tool_menu = QMenu(self._calendar_button)
        self._calendar_widget = QCalendarWidget(tool_menu)
        action = QWidgetAction(tool_menu)
        action.setDefaultWidget(self._calendar_widget)
        tool_menu.addAction(action)
        self._calendar_button.setMenu(tool_menu)

        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self._line_edit)
        layout.addWidget(self._calendar_button)
        self.setLayout(layout)

        self._calendar_widget.activated.connect(self.setDate)
예제 #22
0
    def __init__(self, workflowview: QAbstractItemView):
        super(WorkflowWidget, self).__init__()

        self.view = workflowview

        self.toolbar = QToolBar()
        self.addfunctionmenu = QToolButton()
        self.addfunctionmenu.setIcon(QIcon(path("icons/addfunction.png")))
        self.addfunctionmenu.setText("Add Function")
        # Defer menu population to once the plugins have been loaded; otherwise, the menu may not contain anything
        # if this widget is init'd before all plugins have been loaded.
        self.functionmenu = QMenu()
        self.functionmenu.aboutToShow.connect(self.populateFunctionMenu)
        self.addfunctionmenu.setMenu(self.functionmenu)
        self.addfunctionmenu.setPopupMode(QToolButton.InstantPopup)
        self.toolbar.addWidget(self.addfunctionmenu)
        # self.toolbar.addAction(QIcon(path('icons/up.png')), 'Move Up')
        # self.toolbar.addAction(QIcon(path('icons/down.png')), 'Move Down')
        self.toolbar.addAction(QIcon(path("icons/folder.png")), "Load Workflow")
        self.toolbar.addAction(QIcon(path("icons/trash.png")), "Delete Operation", self.deleteProcess)

        v = QVBoxLayout()
        v.addWidget(self.view)
        v.addWidget(self.toolbar)
        v.setContentsMargins(0, 0, 0, 0)
        self.setLayout(v)
예제 #23
0
    def __init__(self, current_case):
        QWidget.__init__(self)

        self.__model = PlotCaseModel()

        self.__signal_mapper = QSignalMapper(self)
        self.__case_selectors = {}
        self.__case_selectors_order = []

        layout = QVBoxLayout()

        add_button_layout = QHBoxLayout()
        self.__add_case_button = QToolButton()
        self.__add_case_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self.__add_case_button.setText("Add case to plot")
        self.__add_case_button.setIcon(resourceIcon("ide/small/add"))
        self.__add_case_button.clicked.connect(self.addCaseSelector)

        add_button_layout.addStretch()
        add_button_layout.addWidget(self.__add_case_button)
        add_button_layout.addStretch()

        layout.addLayout(add_button_layout)

        self.__case_layout = QVBoxLayout()
        self.__case_layout.setContentsMargins(0, 0, 0, 0)
        layout.addLayout(self.__case_layout)

        self.addCaseSelector(disabled=True, current_case=current_case)
        layout.addStretch()

        self.setLayout(layout)

        self.__signal_mapper.mapped[QWidget].connect(self.removeWidget)
예제 #24
0
    def __init__(self,
                 parent,
                 regex_base=None,
                 key_filter_dict=None,
                 find_on_change=False):
        super().__init__(parent)
        # Parent is assumed to be a spyder widget
        self.text_finder = FinderLineEdit(self,
                                          regex_base=regex_base,
                                          key_filter_dict=key_filter_dict)
        self.text_finder.sig_find_requested.connect(self.do_find)
        if find_on_change:
            self.text_finder.textChanged.connect(self.do_find)
        self.text_finder.sig_hide_requested.connect(
            self.sig_hide_finder_requested)

        self.finder_close_button = QToolButton(self)
        self.finder_close_button.setIcon(ima.icon('DialogCloseButton'))
        self.finder_close_button.clicked.connect(
            self.sig_hide_finder_requested)

        finder_layout = QHBoxLayout()
        finder_layout.addWidget(self.finder_close_button)
        finder_layout.addWidget(self.text_finder)
        finder_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(finder_layout)
        self.setVisible(False)
예제 #25
0
def create_toolbutton(parent, text=None, shortcut=None, icon=None, tip=None,
                      toggled=None, triggered=None,
                      autoraise=True, text_beside_icon=False,
                      section=None, option=None, id_=None, plugin=None,
                      context_name=None, register_toolbutton=False):
    """Create a QToolButton"""
    button = QToolButton(parent)
    if text is not None:
        button.setText(text)
    if icon is not None:
        if is_text_string(icon):
            icon = ima.get_icon(icon)
        button.setIcon(icon)
    if text is not None or tip is not None:
        button.setToolTip(text if tip is None else tip)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    button.setAutoRaise(autoraise)
    if triggered is not None:
        button.clicked.connect(triggered)
    if toggled is not None:
        setup_toggled_action(button, toggled, section, option)
    if shortcut is not None:
        button.setShortcut(shortcut)
    if id_ is not None:
        button.ID = id_

    if register_toolbutton:
        TOOLBUTTON_REGISTRY.register_reference(
            button, id_, plugin, context_name)
    return button
예제 #26
0
    def __init__(self, config_file):
        QWidget.__init__(self)
        self._config_file = config_file
        self._ee_config = None
        if FeatureToggling.is_enabled("ensemble-evaluator"):
            self._ee_config = EvaluatorServerConfig()

        self.setObjectName("Simulation_panel")
        layout = QVBoxLayout()

        self._simulation_mode_combo = QComboBox()
        self._simulation_mode_combo.setObjectName("Simulation_mode")
        addHelpToWidget(self._simulation_mode_combo, "run/simulation_mode")

        self._simulation_mode_combo.currentIndexChanged.connect(
            self.toggleSimulationMode)

        simulation_mode_layout = QHBoxLayout()
        simulation_mode_layout.addSpacing(10)
        simulation_mode_layout.addWidget(QLabel("Simulation mode:"), 0,
                                         Qt.AlignVCenter)
        simulation_mode_layout.addWidget(self._simulation_mode_combo, 0,
                                         Qt.AlignVCenter)

        simulation_mode_layout.addSpacing(20)

        self.run_button = QToolButton()
        self.run_button.setObjectName("start_simulation")
        self.run_button.setIconSize(QSize(32, 32))
        self.run_button.setText("Start Simulation")
        self.run_button.setIcon(resourceIcon("ide/gear_in_play"))
        self.run_button.clicked.connect(self.runSimulation)
        self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        addHelpToWidget(self.run_button, "run/start_simulation")

        simulation_mode_layout.addWidget(self.run_button)
        simulation_mode_layout.addStretch(1)

        layout.addSpacing(5)
        layout.addLayout(simulation_mode_layout)
        layout.addSpacing(10)

        self._simulation_stack = QStackedWidget()
        self._simulation_stack.setLineWidth(1)
        self._simulation_stack.setFrameStyle(QFrame.StyledPanel)

        layout.addWidget(self._simulation_stack)

        self._simulation_widgets = OrderedDict()
        """ :type: OrderedDict[BaseRunModel,SimulationConfigPanel]"""
        self.addSimulationConfigPanel(SingleTestRunPanel())
        self.addSimulationConfigPanel(EnsembleExperimentPanel())
        if ERT.ert.have_observations():
            self.addSimulationConfigPanel(EnsembleSmootherPanel())
            self.addSimulationConfigPanel(MultipleDataAssimilationPanel())
            self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel())

        self.setLayout(layout)
예제 #27
0
    def __init__(self,
                 colormap: BaseColormap,
                 accepted: bool,
                 name: str,
                 removable: bool = False,
                 used: bool = False):
        super().__init__()
        self.image = convert_colormap_to_image(colormap)
        self.name = name
        self.removable = removable
        self.checked = QCheckBox()
        self.checked.setChecked(accepted)
        self.checked.setDisabled(used)
        self.setMinimumWidth(80)
        metrics = QFontMetrics(QFont())
        layout = QHBoxLayout()
        layout.addWidget(self.checked)
        layout.addStretch(1)
        self.remove_btn = QToolButton()
        self.remove_btn.setIcon(_icon_selector.close_icon)
        if removable:
            self.remove_btn.setToolTip("Remove colormap")
        else:
            self.remove_btn.setToolTip("This colormap is protected")
        self.remove_btn.setEnabled(not accepted and self.removable)

        self.edit_btn = QToolButton()
        self.edit_btn.setIcon(_icon_selector.edit_icon)
        layout.addWidget(self.remove_btn)
        layout.addWidget(self.edit_btn)
        self.setLayout(layout)
        self.checked.stateChanged.connect(self._selection_changed)
        self.edit_btn.clicked.connect(partial(self.edit_request.emit, name))
        if isinstance(colormap, ColorMap):
            self.edit_btn.clicked.connect(
                partial(self.edit_request[ColorMap].emit, colormap))
            self.edit_btn.setToolTip("Create colormap base on this")
        else:
            self.edit_btn.setDisabled(True)
            self.edit_btn.setToolTip("This colormap is not editable")
        self.remove_btn.clicked.connect(partial(self.remove_request.emit,
                                                name))
        self.setMinimumHeight(
            max(metrics.height(), self.edit_btn.minimumHeight(),
                self.checked.minimumHeight()) + 20)
예제 #28
0
    def __init__(self, *args, **kwargs):
        super(MOSViewerToolbar, self).__init__(*args, **kwargs)
        self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        # Define the toolbar actions
        self.cycle_previous_action = QAction(
            QIcon(os.path.join(ICON_DIR, "Previous-96.png")), "Previous", self)
        self.cycle_next_action = QAction(
            QIcon(os.path.join(ICON_DIR, "Next-96.png")), "Next", self)

        # Include the dropdown widget
        self.source_select = QComboBox()

        # Add the items to the toolbar
        self.addAction(self.cycle_previous_action)
        self.addAction(self.cycle_next_action)
        self.addWidget(self.source_select)

        # Include a button to open spectrum in specviz
        self.open_specviz = QAction(
            QIcon(os.path.join(ICON_DIR, "External-96.png")),
            "Open in SpecViz", self)

        # Create a tool button to hold the lock axes menu object
        tool_button = QToolButton(self)
        tool_button.setText("Axes Settings")
        tool_button.setIcon(QIcon(os.path.join(ICON_DIR, "Settings-96.png")))
        tool_button.setPopupMode(QToolButton.MenuButtonPopup)
        tool_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        # Create a menu for the axes settings drop down
        self.settings_menu = QMenu(self)

        # Add lock x axis action
        self.lock_x_action = QAction("Lock spectral axis", self.settings_menu)
        self.lock_x_action.setCheckable(True)

        # Add lock y axis action
        self.lock_y_action = QAction("Lock vertical displacement axis",
                                     self.settings_menu)
        self.lock_y_action.setCheckable(True)

        # Add the actions to the menu
        self.settings_menu.addAction(self.lock_x_action)
        self.settings_menu.addAction(self.lock_y_action)

        # Set the menu object on the tool button
        tool_button.setMenu(self.settings_menu)

        # Create a widget action object to hold the tool button, this way the
        # toolbar behaves the way it's expected to
        tool_button_action = QWidgetAction(self)
        tool_button_action.setDefaultWidget(tool_button)

        self.addAction(tool_button_action)
        self.addSeparator()
        self.addAction(self.open_specviz)
예제 #29
0
 def __init__(self):
     super().__init__()
     self.setFloatable(False)
     self.setMovable(False)
     self.setLayoutDirection(Qt.RightToLeft)
     self.hide_button = QToolButton()
     self.hide_button.setObjectName("hidebutton")
     self.hide_button.setArrowType(Qt.UpArrow)
     self.addWidget(self.hide_button)
예제 #30
0
def action2button(action, autoraise=True, text_beside_icon=False, parent=None):
    """Create a QToolButton directly from a QAction object"""
    if parent is None:
        parent = action.parent()
    button = QToolButton(parent)
    button.setDefaultAction(action)
    button.setAutoRaise(autoraise)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    return button