示例#1
0
class Legend(QWidget):
    """Combines a LegendMarker with a label"""
    def __init__(self, legend, color):
        QWidget.__init__(self)

        self.setMinimumWidth(140)
        self.setMaximumHeight(25)

        self.legend = legend

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

        self.legend_marker = LegendMarker(color)
        self.legend_marker.setToolTip(legend)

        layout.addWidget(self.legend_marker)
        self.legend_label = QLabel(legend)
        layout.addWidget(self.legend_label)
        layout.addStretch()

        self.setLayout(layout)

    def setLegend(self, legend):
        self.legend_label.setText(legend)

    def updateLegend(self, *args):
        legend_text = self.legend % args
        self.legend_label.setText(legend_text)
        self.legend_marker.setToolTip(legend_text)

    def setColor(self, color):
        self.legend_marker.color = color
        self.legend_marker.update()
示例#2
0
    def __init__(self,
                 title="Title",
                 description="Description",
                 unique_names=None,
                 choose_from_list=False):
        QDialog.__init__(self)
        self.setModal(True)
        self.setWindowTitle(title)
        # self.setMinimumWidth(250)
        # self.setMinimumHeight(150)

        if unique_names is None:
            unique_names = []

        self.unique_names = unique_names
        self.choose_from_list = choose_from_list

        self.layout = QFormLayout()
        self.layout.setSizeConstraint(QLayout.SetFixedSize)

        label = QLabel(description)
        label.setAlignment(Qt.AlignHCenter)

        self.layout.addRow(self.createSpace(5))
        self.layout.addRow(label)
        self.layout.addRow(self.createSpace(10))

        buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
        self.ok_button = buttons.button(QDialogButtonBox.Ok)
        self.ok_button.setEnabled(False)

        if choose_from_list:
            self.param_name_combo = QComboBox()
            self.param_name.currentIndexChanged.connect(self.validateChoice)
            for item in unique_names:
                self.param_name_combo.addItem(item)
            self.layout.addRow("Job:", self.param_name_combo)
        else:
            self.param_name = QLineEdit(self)
            self.param_name.setFocus()
            self.param_name.textChanged.connect(self.validateName)
            self.validColor = self.param_name.palette().color(
                self.param_name.backgroundRole())

            self.layout.addRow("Name:", self.param_name)

        self.layout.addRow(self.createSpace(10))

        self.layout.addRow(buttons)

        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)

        self.setLayout(self.layout)
示例#3
0
    def __init__(self, model, help_link=""):
        QLabel.__init__(self)

        addHelpToWidget(self, help_link)
        self._model = model

        font = self.font()
        font.setWeight(QFont.Bold)
        self.setFont(font)

        self._model.valueChanged.connect(self.updateLabel)

        self.updateLabel()
示例#4
0
    def __init__(self):
        QWidget.__init__(self)

        addHelpToWidget(self, "init/case_list")

        layout = QVBoxLayout()

        self._list = QListWidget(self)
        self._list.setMinimumHeight(100)
        self._list.setMaximumHeight(250)
        self._default_selection_mode = self._list.selectionMode()
        self.setSelectable(False)

        layout.addWidget(QLabel("Available Cases:"))
        layout.addWidget(self._list)

        self._addRemoveWidget = AddRemoveWidget(self.addItem,
                                                self.removeItem,
                                                horizontal=True)
        self._addRemoveWidget.enableRemoveButton(False)
        layout.addWidget(self._addRemoveWidget)

        self._title = "New keyword"
        self._description = "Enter name of keyword:"

        self.setLayout(layout)

        ERT.ertChanged.connect(self.updateList)
        self.updateList()
示例#5
0
    def __init__(self):
        QWidget.__init__(self, None, Qt.ToolTip)
        self.resize(300, 50)

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

        self._error_widget = QLabel("")
        self._error_widget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
        self._error_widget.setFrameStyle(QFrame.Box)
        self._error_widget.setWordWrap(True)
        self._error_widget.setScaledContents(True)
        # self.warning_widget.setAlignment(Qt.AlignHCenter)
        self._error_widget.setTextFormat(Qt.RichText)
        layout.addWidget(self._error_widget)

        self.setLayout(layout)
示例#6
0
    def __init__(self, legend, color):
        QWidget.__init__(self)

        self.setMinimumWidth(140)
        self.setMaximumHeight(25)

        self.legend = legend

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

        self.legend_marker = LegendMarker(color)
        self.legend_marker.setToolTip(legend)

        layout.addWidget(self.legend_marker)
        self.legend_label = QLabel(legend)
        layout.addWidget(self.legend_label)
        layout.addStretch()

        self.setLayout(layout)
示例#7
0
    def __init__(self, title="Title", description="Description", parent=None):
        QDialog.__init__(self, parent)

        self._option_list = []
        """ :type: list of QWidget """

        self.setModal(True)
        self.setWindowTitle(title)

        self.layout = QFormLayout()
        self.layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
        self.layout.setSizeConstraint(QLayout.SetFixedSize)

        label = QLabel(description)
        label.setAlignment(Qt.AlignHCenter)

        self.layout.addRow(self.createSpace(5))
        self.layout.addRow(label)
        self.layout.addRow(self.createSpace(10))

        self.ok_button = None

        self.setLayout(self.layout)
示例#8
0
    def addColumn(self, text):
        layout = QVBoxLayout()
        text_widget = QLabel(text)
        text_widget.setWordWrap(True)
        text_widget.setTextFormat(Qt.RichText)
        layout.addWidget(text_widget)
        layout.addStretch(1)

        self.layout.addLayout(layout)
示例#9
0
    def __init__(self):
        QWidget.__init__(self)

        layout = QVBoxLayout()

        self._simulation_mode_combo = QComboBox()
        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.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)
示例#10
0
    def __init__(self,
                 model,
                 label="",
                 help_link="",
                 custom_filter_button=None):
        """
        :param custom_filter_button:  if needed, add a button that opens a custom filter menu. Useful when search alone
        isn't enough to filter the list.
        :type custom_filter_button: QToolButton
        """
        QWidget.__init__(self)

        self._model = model

        if help_link != "":
            addHelpToWidget(self, help_link)

        layout = QVBoxLayout()

        self._createCheckButtons()

        self._list = QListWidget()
        self._list.setContextMenuPolicy(Qt.CustomContextMenu)
        self._list.setSelectionMode(QAbstractItemView.ExtendedSelection)

        self._search_box = SearchBox()

        check_button_layout = QHBoxLayout()

        check_button_layout.setContentsMargins(0, 0, 0, 0)
        check_button_layout.setSpacing(0)
        check_button_layout.addWidget(QLabel(label))
        check_button_layout.addStretch(1)
        check_button_layout.addWidget(self._checkAllButton)
        check_button_layout.addWidget(self._uncheckAllButton)

        layout.addLayout(check_button_layout)
        layout.addWidget(self._list)
        """
        Inserts the custom filter button, if provided. The caller is responsible for all related actions.
        """
        if custom_filter_button is not None:
            search_bar_layout = QHBoxLayout()
            search_bar_layout.addWidget(self._search_box)
            search_bar_layout.addWidget(custom_filter_button)
            layout.addLayout(search_bar_layout)
        else:
            layout.addWidget(self._search_box)

        self.setLayout(layout)

        self._checkAllButton.clicked.connect(self.checkAll)
        self._uncheckAllButton.clicked.connect(self.uncheckAll)
        self._list.itemChanged.connect(self.itemChanged)
        self._search_box.filterChanged.connect(self.filterList)
        self._list.customContextMenuRequested.connect(self.showContextMenu)

        self._model.selectionChanged.connect(self.modelChanged)
        self._model.modelChanged.connect(self.modelChanged)

        self.modelChanged()
示例#11
0
class ErrorPopup(QWidget):
    error_template = ("<html>"
                      "<table style='background-color: #ffdfdf;'width='100%%'>"
                      "<tr><td style='font-weight: bold; padding-left: 5px;'>Warning:</td></tr>"
                      "%s"
                      "</table>"
                      "</html>")

    def __init__(self):
        QWidget.__init__(self, None, Qt.ToolTip)
        self.resize(300, 50)

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

        self._error_widget = QLabel("")
        self._error_widget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
        self._error_widget.setFrameStyle(QFrame.Box)
        self._error_widget.setWordWrap(True)
        self._error_widget.setScaledContents(True)
        # self.warning_widget.setAlignment(Qt.AlignHCenter)
        self._error_widget.setTextFormat(Qt.RichText)
        layout.addWidget(self._error_widget)

        self.setLayout(layout)

    def presentError(self, widget, error):
        assert isinstance(widget, QWidget)

        self._error_widget.setText(ErrorPopup.error_template % error)
        self.show()

        size_hint = self.sizeHint()
        rect = widget.rect()
        p = widget.mapToGlobal(QPoint(rect.left(), rect.top()))

        self.setGeometry(p.x(), p.y() - size_hint.height() - 5, size_hint.width(), size_hint.height())

        self.raise_()
    def __init__(self, analysis_module_name, parent=None):
        QWidget.__init__(self, parent)

        self._analysis_module_name = analysis_module_name

        layout = QFormLayout()
        variable_names = AnalysisModuleVariablesModel.getVariableNames(
            self._analysis_module_name)

        if len(variable_names) == 0:
            label = QLabel("No variables found to edit")
            boxlayout = QHBoxLayout()
            layout.addRow(label, boxlayout)

        else:
            analysis_module_variables_model = AnalysisModuleVariablesModel
            self.blockSignals(True)

            variable_names2 = self.sortVariables(variable_names)
            for variable_name in variable_names2:
                variable_type = analysis_module_variables_model.getVariableType(
                    variable_name)
                variable_value = analysis_module_variables_model.getVariableValue(
                    self._analysis_module_name, variable_name)

                label_name = analysis_module_variables_model.getVariableLabelName(
                    variable_name)
                if variable_type == bool:
                    spinner = self.createCheckBox(variable_name,
                                                  variable_value,
                                                  variable_type)

                elif variable_type == float:
                    spinner = self.createDoubleSpinBox(
                        variable_name, variable_value, variable_type,
                        analysis_module_variables_model)

                elif variable_type == str:
                    spinner = self.createLineEdit(variable_name,
                                                  variable_value,
                                                  variable_type)

                elif variable_type == int:
                    spinner = self.createSpinBox(
                        variable_name, variable_value, variable_type,
                        analysis_module_variables_model)

                layout.addRow(label_name, spinner)
                if variable_name == "LAMBDA0":
                    label = QLabel(
                        "<span style=\"font-size:12pt; font-weight:300;font-style:italic;\"> Initial Lambda of -1.00 signifies that the value will be calculated</span>"
                    )
                    layout.addRow(label, None)

                if variable_name == "IES_INVERSION":
                    label = QLabel(
                        "<span style=\"font-size:10pt; font-weight:300;font-style:italic;\">   0: Exact inversion with diagonal R=I</span>"
                    )
                    layout.addRow(label, None)
                    label = QLabel(
                        "<span style=\"font-size:10pt; font-weight:300;font-style:italic;\">   1: Subspace inversion with exact R  </span>"
                    )
                    layout.addRow(label, None)
                    label = QLabel(
                        "<span style=\"font-size:10pt; font-weight:300;font-style:italic;\">   2: Subspace inversion using R=EE'   </span>"
                    )
                    layout.addRow(label, None)
                    label = QLabel(
                        "<span style=\"font-size:10pt; font-weight:300;font-style:italic;\">   3: Subspace inversion using E       </span>"
                    )
                    layout.addRow(label, None)

                if variable_name == "IES_DEC_STEPLENGTH":
                    label = QLabel(
                        "<span style=\"font-size:10pt; font-weight:300;font-style:italic;\">   A good start is max steplength of 0.6, min steplength of 0.3, and decline of 2.5</span>"
                    )
                    layout.addRow(label, None)
                    label = QLabel(
                        "<span style=\"font-size:10pt; font-weight:300;font-style:italic;\">   A steplength of 1.0 and one iteration results in ES update</span>"
                    )
                    layout.addRow(label, None)

                if variable_name == "IES_AAPROJECTION":
                    label = QLabel(
                        "<span style=\"font-size:10pt; font-weight:300;font-style:italic;\">   Only impacts estimate when n less than N-1</span>"
                    )
                    label = QLabel(
                        "<span style=\"font-size:10pt; font-weight:300;font-style:italic;\">   Any benefit of using the projection is unclear</span>"
                    )
                    layout.addRow(label, None)

        self.setLayout(layout)
        self.blockSignals(False)