def __init__(self, iterable=False, load_all = False, help_link=""): QWidget.__init__(self) self._iterable = iterable addHelpToWidget(self, help_link) layout = QHBoxLayout() analysis_module_combo = QComboBox() self._module_names = getAnalysisModuleNames(self._iterable) if load_all: self._module_names += getAnalysisModuleNames(not self._iterable) suffix = {'STD_ENKF': " - Recommended"} for module_name in self._module_names: analysis_module_combo.addItem(module_name + suffix.get(module_name, "")) self._current_module_name = self._getCurrentAnalysisModuleName() if self._current_module_name is not None: analysis_module_combo.setCurrentIndex(self._module_names.index(self._current_module_name)) analysis_module_combo.currentIndexChanged[int].connect(self.analysisModuleChanged) variables_popup_button = QToolButton() variables_popup_button.setIcon(resourceIcon("ide/small/cog_edit.png")) variables_popup_button.clicked.connect(self.showVariablesPopup) variables_popup_button.setMaximumSize(20, 20) layout.addWidget(analysis_module_combo, 0, Qt.AlignLeft) layout.addWidget(variables_popup_button, 0, Qt.AlignLeft) layout.setContentsMargins(QMargins(0, 0, 0, 0)) layout.addStretch() self.setLayout(layout)
class SummaryPanel(QFrame): def __init__(self, parent=None): QFrame.__init__(self, parent) self.setMinimumWidth(250) self.setMinimumHeight(150) widget = QWidget() self.layout = QHBoxLayout() widget.setLayout(self.layout) scroll = QScrollArea() scroll.setWidgetResizable(True) scroll.setWidget(widget) layout = QGridLayout() layout.addWidget(scroll) self.setLayout(layout) self.updateSummary() def updateSummary(self): summary = ErtSummary() text = SummaryTemplate("Forward Model") for job in summary.getForwardModels(): text.addRow(job) self.addColumn(text.getText()) text = SummaryTemplate("Parameters") for parameters in summary.getParameters(): text.addRow(parameters) self.addColumn(text.getText()) text = SummaryTemplate("Observations") for observations in summary.getObservations(): text.addRow(observations) self.addColumn(text.getText()) 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)
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("ide/small/add")) 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, addFunction=None, removeFunction=None, horizontal=False): QWidget.__init__(self) self.addButton = QToolButton(self) self.addButton.setIcon(resourceIcon("add")) self.addButton.setIconSize(QSize(16, 16)) self.addButton.clicked.connect(addFunction) self.removeButton = QToolButton(self) self.removeButton.setIcon(resourceIcon("remove")) 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)
def __init__(self, parent=None): QFrame.__init__(self, parent) self.setMinimumWidth(250) self.setMinimumHeight(150) widget = QWidget() self.layout = QHBoxLayout() widget.setLayout(self.layout) scroll = QScrollArea() scroll.setWidgetResizable(True) scroll.setWidget(widget) layout = QGridLayout() layout.addWidget(scroll) self.setLayout(layout) self.updateSummary()
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 __init__(self, title, widget, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(title) self.setModal(True) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setWindowFlags(self.windowFlags() & ~Qt.WindowCloseButtonHint) layout = QVBoxLayout() layout.setSizeConstraint(QLayout.SetFixedSize) # not resizable!!! layout.addWidget(widget) self.__button_layout = QHBoxLayout() self.close_button = QPushButton("Close") self.close_button.setObjectName("CLOSE") self.close_button.clicked.connect(self.accept) self.__button_layout.addStretch() self.__button_layout.addWidget(self.close_button) layout.addStretch() layout.addLayout(self.__button_layout) self.setLayout(layout)
def __init__(self, model, help_link=""): """ :type model: ert_gui.ertwidgets.models.path_model.PathModel :param help_link: str """ QWidget.__init__(self) addHelpToWidget(self, help_link) self._validation_support = ValidationSupport(self) self._editing = True layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self._path_line = QLineEdit() self._path_line.setMinimumWidth(250) layout.addWidget(self._path_line) dialog_button = QToolButton(self) dialog_button.setIcon(resourceIcon("ide/small/folder")) dialog_button.setIconSize(QSize(16, 16)) dialog_button.clicked.connect(self.selectPath) layout.addWidget(dialog_button) self.valid_color = self._path_line.palette().color( self._path_line.backgroundRole()) self._path_line.setText(os.getcwd()) self._editing = False self._model = model self._model.valueChanged.connect(self.getPathFromModel) self._path_line.editingFinished.connect(self.validatePath) self._path_line.editingFinished.connect(self.contentsChanged) self._path_line.textChanged.connect(self.validatePath) self.setLayout(layout) self.getPathFromModel()
class ClosableDialog(QDialog): def __init__(self, title, widget, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(title) self.setModal(True) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setWindowFlags(self.windowFlags() & ~Qt.WindowCloseButtonHint) layout = QVBoxLayout() layout.setSizeConstraint(QLayout.SetFixedSize) # not resizable!!! layout.addWidget(widget) self.__button_layout = QHBoxLayout() self.close_button = QPushButton("Close") self.close_button.setObjectName("CLOSE") self.close_button.clicked.connect(self.accept) self.__button_layout.addStretch() self.__button_layout.addWidget(self.close_button) layout.addStretch() layout.addLayout(self.__button_layout) self.setLayout(layout) def disableCloseButton(self): self.close_button.setEnabled(False) def enableCloseButton(self): self.close_button.setEnabled(True) def keyPressEvent(self, q_key_event): if not self.close_button.isEnabled() and q_key_event.key( ) == Qt.Key_Escape: pass else: QDialog.keyPressEvent(self, q_key_event) def addButton(self, caption, listner): button = QPushButton(caption) button.setObjectName(str(caption).capitalize()) self.__button_layout.insertWidget(1, button) button.clicked.connect(listner) def toggleButton(self, caption, enabled): button = self.findChild(QPushButton, str(caption).capitalize()) if button is not None: button.setEnabled(enabled)
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()
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)
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)