コード例 #1
0
ファイル: widget.py プロジェクト: samueljackson92/mantid
class AlgorithmProgressWidget(QWidget):
    """
    Widget consisting of a progress bar and a button.
    """
    def __init__(self, parent=None):
        super(AlgorithmProgressWidget, self).__init__(parent)
        self.progress_bar = None
        self.details_button = QPushButton('Details')
        self.details_button.clicked.connect(self.show_dialog)
        self.layout = QHBoxLayout()
        self.layout.addStretch()
        self.layout.addWidget(self.details_button)
        self.setLayout(self.layout)
        self.presenter = AlgorithmProgressPresenter(self)

    def show_progress_bar(self):
        if self.progress_bar is None:
            self.progress_bar = QProgressBar()
            self.progress_bar.setAlignment(Qt.AlignHCenter)
            self.layout.insertWidget(0, self.progress_bar)
            self.layout.removeItem(self.layout.takeAt(1))

    def hide_progress_bar(self):
        if self.progress_bar is not None:
            self.layout.insertStretch(0)
            self.layout.removeWidget(self.progress_bar)
            self.progress_bar.close()
            self.progress_bar = None

    def show_dialog(self):
        dialog = AlgorithmMonitorDialog(self, self.presenter.model)
        dialog.show()
コード例 #2
0
ファイル: mxexplorer.py プロジェクト: fumitoh/spyder-modelx
        def __init__(self, parent, **kwargs):

            QWidget.__init__(self, parent)
            self.plugin = parent.get_plugin()
            self.last_modelpath = None

            # Create and place Model Selector
            txt = _("Model")
            if sys.platform == 'darwin':
                expr_label = QLabel("  " + txt)
            else:
                expr_label = QLabel(txt)

            # expr_label.setAlignment(Qt.AlignCenter | Qt.AlignRight)
            self.model_selector = MxModelSelector(self)
            selector_layout = QHBoxLayout()
            selector_layout.addWidget(expr_label)
            selector_layout.addWidget(self.model_selector)
            selector_layout.insertStretch(-1, 1)
            selector_layout.setStretch(0, 0)
            selector_layout.setStretch(1, 1)

            # Create widget and add to dockwindow
            self.explorer = MxExplorer(self)

            # Create code list
            self.codelist = MxCodeListWidget(self)
            self.propwidget = MxPropertyWidget(self, orientation=Qt.Vertical)
            self.datalist = MxDataListWidget(self, orientation=Qt.Vertical)

            # Create splitter
            self.splitter = QSplitter(self)
            self.splitter.setContentsMargins(0, 0, 0, 0)
            # self.splitter.addWidget(self.widget)
            # self.splitter.setStretchFactor(0, 5)
            # self.splitter.setStretchFactor(1, 1)

            self.tabwidget = QTabWidget(parent=self)
            # self.tabwidget.setContentsMargins(0, 0, 0, 0)
            MxMainWidget.IdxProperties = self.tabwidget.addTab(self.propwidget, "Properties")
            MxMainWidget.IdxFormulas = self.tabwidget.addTab(self.codelist, "Formulas")
            MxMainWidget.IdxDataList = self.tabwidget.addTab(self.datalist, "Data")

            # Layout management
            self.splitter.addWidget(self.explorer)
            self.splitter.addWidget(self.tabwidget)

            layout = create_plugin_layout(selector_layout, self.splitter)
            self.setLayout(layout)

            self.setFocusPolicy(Qt.ClickFocus)
コード例 #3
0
class Titlebar(QFrame):
    """Titlebar for frameless windows."""

    minimizeClicked = Signal()
    maximizeClicked = Signal()
    restoreClicked = Signal()
    closeClicked = Signal()

    def __init__(self, parent=None):
        super(Titlebar, self).__init__(parent)
        self.setObjectName("titlebar")
        self.setMouseTracking(True)

        self.menus = []

        self.setAutoFillBackground(True)
        self.setFixedHeight(30)
        self.setContentsMargins(0, 0, 0, 0)
        self.setBackgroundRole(QPalette.Highlight)

        self.layout = QHBoxLayout(self)
        self.layout.setAlignment(Qt.AlignVCenter)
        self.layout.setAlignment(Qt.AlignLeft)
        self.layout.setContentsMargins(8, 0, 0, 0)
        self.layout.setSpacing(0)
        self.setLayout(self.layout)

        self.appLogoLabel = AppLogo(self)
        if qrainbowstyle.APP_ICON_PATH:
            self.appLogoLabel.setPixmap(QPixmap(qrainbowstyle.APP_ICON_PATH))
            self.layout.setContentsMargins(2, 0, 0, 0)
        self.layout.addWidget(self.appLogoLabel)
        if qrainbowstyle.ALIGN_BUTTONS_LEFT:
            self.appLogoLabel.setVisible(False)
            self.layout.setContentsMargins(8, 0, 0, 0)

        self.layout.insertStretch(50)
        self.buttonsWidget = ButtonsWidget(self)
        if qrainbowstyle.ALIGN_BUTTONS_LEFT:
            self.layout.insertWidget(0, self.buttonsWidget)
        else:
            self.layout.addWidget(self.buttonsWidget)

        # auto connect signals
        QMetaObject.connectSlotsByName(self)
        if self.window().parent() is not None:
            self.buttonsWidget.btnRestore.setVisible(False)
            self.buttonsWidget.btnMaximize.setVisible(False)
            self.buttonsWidget.btnMinimize.setVisible(False)

    def setWindowIcon(self, icon: QIcon):
        self.appLogoLabel.setPixmap(icon.pixmap())

    # connecting buttons signals
    @Slot()
    def on_btnClose_clicked(self):
        self.closeClicked.emit()

    @Slot()
    def on_btnRestore_clicked(self):
        self.showRestoreButton(False)
        self.showMaximizeButton(True)
        self.window().showNormal()
        self.restoreClicked.emit()

    @Slot()
    def on_btnMaximize_clicked(self):
        if qrainbowstyle.USE_DARWIN_BUTTONS:
            if self.window().isMaximized():
                self.window().showNormal()
            else:
                self.window().showMaximized()
        else:
            self.showRestoreButton(True)
            self.showMaximizeButton(False)
            self.window().showMaximized()
        self.maximizeClicked.emit()

    @Slot()
    def on_btnMinimize_clicked(self):
        self.window().showMinimized()

    def showLogo(self, value: bool):
        """Show or hide app logo label"""
        self.appLogoLabel.setVisible(value)

    def showRestoreButton(self, value):
        if self.window().parent() is None:
            self.buttonsWidget.btnRestore.setVisible(value)

    def showMaximizeButton(self, value):
        if self.window().parent() is None:
            self.buttonsWidget.btnMaximize.setVisible(value)

    def showMinimizeButton(self, value):
        if self.window().parent() is None:
            self.buttonsWidget.btnMinimize.setVisible(value)

    def addMenu(self, menu: QMenu):
        menuButton = MenuButton(self)
        menuButton.setMenu(menu)
        menuButton.setText(menu.title())
        self.layout.insertWidget(len(self.menus) + 1, menuButton)
        self.menus.append(menuButton)

    def setTitlebarHeight(self, height: int):
        self.setFixedHeight(height)

    def mouseOverTitlebar(self, x, y):
        if self.childAt(QPoint(x, y)):
            return False
        else:
            return QRect(self.appLogoLabel.width(), 0,
                         self.width() - self.appLogoLabel.width(),
                         self.height()).contains(QPoint(x, y))