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.connect(self.addButton, SIGNAL("clicked()"), addFunction) self.removeButton = QToolButton(self) self.removeButton.setIcon(resourceIcon("remove")) self.removeButton.setIconSize(QSize(16, 16)) self.connect(self.removeButton, SIGNAL("clicked()"), removeFunction) if horizontal: self.buttonLayout = QHBoxLayout() else: self.buttonLayout = QVBoxLayout() self.buttonLayout.setMargin(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 createButtons(self): """Create kill, restart and resample and restart buttons""" self.killButton = QtGui.QToolButton(self) self.killButton.setIcon(resourceIcon("cross")) self.killButton.setToolTip("Kill job") self.connect(self.killButton, QtCore.SIGNAL('clicked()'), self.ctrl.kill) self.restartButton = QtGui.QToolButton(self) self.restartButton.setIcon(resourceIcon("refresh")) self.restartButton.setToolTip("Restart job") self.connect(self.restartButton, QtCore.SIGNAL('clicked()'), lambda: self.ctrl.restart(False)) self.rrButton = QtGui.QToolButton(self) self.rrButton.setIcon(resourceIcon("refresh_resample")) self.rrButton.setToolTip("Resample and restart job") self.connect(self.rrButton, QtCore.SIGNAL('clicked()'), lambda: self.ctrl.restart(True)) buttonLayout = QtGui.QHBoxLayout() buttonLayout.addWidget(self.killButton) buttonLayout.addWidget(self.restartButton) buttonLayout.addWidget(self.rrButton) return buttonLayout
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.connect(self.addButton, SIGNAL('clicked()'), addFunction) self.removeButton = QToolButton(self) self.removeButton.setIcon(resourceIcon("remove")) self.removeButton.setIconSize(QSize(16, 16)) self.connect(self.removeButton, SIGNAL('clicked()'), removeFunction) if horizontal: self.buttonLayout = QHBoxLayout() else: self.buttonLayout = QVBoxLayout() self.buttonLayout.setMargin(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): QToolBar.__init__(self, "PlotTools") self.setObjectName("PlotToolBar") self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) self.__reset_scales = self.createAction("Reset Scales", util.resourceIcon("ide/transform_scale")) self.__reset_scales.triggered.connect(self.resetScalesClicked) self.__x_min, self.__x_min_action = self.addScaler( "x_min", "X Minimum", spinner_type=CTime, select_min_time_value=True ) self.__x_max, self.__x_max_action = self.addScaler("x_max", "X Maximum", spinner_type=CTime) self.__y_min, self.__y_min_action = self.addScaler( "y_min", "Y Minimum", spinner_type=float, select_min_time_value=True ) self.__y_max, self.__y_max_action = self.addScaler("y_max", "Y Maximum", spinner_type=float) self.__report_step_widget = ReportStepWidget() self.__report_step_widget.reportStepTimeSelected.connect(self.reportStepChanged) self.__report_step_widget.setFontSize(PlotToolBar.FONT_SIZE) self.__report_step_widget_action = self.addWidget(self.__report_step_widget) self.addSeparator() export_action = self.createAction("Export Plot", util.resourceIcon("ide/table_export")) export_action.triggered.connect(self.exportClicked)
def get_typeIcons(cls): if cls.typeIcons__ is None: typeIcons__ = {FieldModel.TYPE: util.resourceIcon("grid_16"), DataModel.TYPE: util.resourceIcon("data"), SummaryModel.TYPE: util.resourceIcon("summary"), KeywordModel.TYPE: util.resourceIcon("key")} return typeIcons__
def __init__(self, config_file_path, help_tool): QWidget.__init__(self) layout = QVBoxLayout() toolbar = QToolBar("toolbar") save_action = toolbar.addAction(util.resourceIcon("ide/disk"), "Save") save_action.triggered.connect(self.save) save_as_action = toolbar.addAction(util.resourceIcon("ide/save_as"), "Save As") save_as_action.triggered.connect(self.saveAs) # reload_icon = toolbar.style().standardIcon(QStyle.SP_BrowserReload) # reload_action = toolbar.addAction(reload_icon, "Reload") # reload_action.triggered.connect(self.reload) toolbar.addSeparator() toolbar.addAction(help_tool.getAction()) stretchy_separator = QWidget() stretchy_separator.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) toolbar.addWidget(stretchy_separator) search = SearchBox() search.setMaximumWidth(200) search.setContentsMargins(5, 2, 5, 2) toolbar.addWidget(search) layout.addWidget(toolbar) self.ide_panel = IdePanel() layout.addWidget(self.ide_panel, 1) self.config_file_path = config_file_path with open(config_file_path) as f: config_file_text = f.read() self.highlighter = KeywordHighlighter(self.ide_panel.document()) search.filterChanged.connect(self.highlighter.setSearchString) self.parseDefines(config_file_text) self.ide_panel.document().setPlainText(config_file_text) cursor = self.ide_panel.textCursor() cursor.setPosition(0) self.ide_panel.setTextCursor(cursor) self.ide_panel.setFocus() self.setLayout(layout)
def __init__(self, model, label="", help_link=""): HelpedWidget.__init__(self, "", help_link) layout = QVBoxLayout() widget = QWidget() widget.setLayout(layout) self.checkAllButton = QToolButton() self.checkAllButton.setIcon(resourceIcon("checked")) 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("notchecked")) self.uncheckAllButton.setIconSize(QSize(16, 16)) self.uncheckAllButton.setToolButtonStyle(Qt.ToolButtonIconOnly) self.uncheckAllButton.setAutoRaise(True) self.uncheckAllButton.setToolTip("Unselect all") self.list = QListWidget() self.list.setContextMenuPolicy(Qt.CustomContextMenu) self.list.setSelectionMode(QAbstractItemView.ExtendedSelection) self.search_box = SearchBox() check_button_layout = QHBoxLayout() check_button_layout.setMargin(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) layout.addWidget(self.search_box) self.addWidget(widget) self.connect(self.checkAllButton, SIGNAL('clicked()'), self.checkAll) self.connect(self.uncheckAllButton, SIGNAL('clicked()'), self.uncheckAll) self.connect(self.list, SIGNAL('itemChanged(QListWidgetItem*)'), self.itemChanged) self.search_box.filterChanged.connect(self.filterList) # self.connect(self.search_box, SIGNAL('filterChanged(str)'), self.filterList) self.connect(self.list, SIGNAL('customContextMenuRequested(QPoint)'), self.showContextMenu) assert isinstance(model, (SelectableModelMixin, ListModelMixin)) self.model = model self.model.observable().attach(SelectableModelMixin.SELECTION_CHANGED_EVENT, self.modelChanged) self.model.observable().attach(ListModelMixin.LIST_CHANGED_EVENT, self.modelChanged) self.modelChanged()
def __init__(self, config_file_path, help_tool): QWidget.__init__(self) layout = QVBoxLayout() toolbar = QToolBar("toolbar") save_action = toolbar.addAction(util.resourceIcon("ide/disk"), "Save") save_action.triggered.connect(self.save) save_as_action = toolbar.addAction(util.resourceIcon("ide/save_as"), "Save As") save_as_action.triggered.connect(self.saveAs) # reload_icon = toolbar.style().standardIcon(QStyle.SP_BrowserReload) # reload_action = toolbar.addAction(reload_icon, "Reload") # reload_action.triggered.connect(self.reload) toolbar.addSeparator() toolbar.addAction(help_tool.getAction()) stretchy_separator = QWidget() stretchy_separator.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) toolbar.addWidget(stretchy_separator) search = SearchBox() search.setMaximumWidth(200) search.setContentsMargins(5, 2, 5, 2) toolbar.addWidget(search) layout.addWidget(toolbar) self.ide_panel = IdePanel() layout.addWidget(self.ide_panel, 1) self.config_file_path = config_file_path with open(config_file_path) as f: config_file_text = f.read() self.highlighter = KeywordHighlighter(self.ide_panel.document()) search.filterChanged.connect(self.highlighter.setSearchString) self.parseDefines(config_file_text) self.ide_panel.document().setPlainText(config_file_text) cursor = self.ide_panel.textCursor() cursor.setPosition(0) self.ide_panel.setTextCursor(cursor) self.ide_panel.setFocus() self.setLayout(layout)
class Parameter(QtGui.QListWidgetItem): """ListWidgetItem class that represents a Parameter with an associated icon.""" typeIcons = { FieldModel.TYPE: util.resourceIcon("grid_16"), DataModel.TYPE: util.resourceIcon("data"), SummaryModel.TYPE: util.resourceIcon("summary"), KeywordModel.TYPE: util.resourceIcon("key") } def __init__(self, name, type, icon=None): if icon is None: icon = Parameter.typeIcons[type] QtGui.QListWidgetItem.__init__(self, icon, name) self.type = type self.name = name self.user_data = None self.setValid(True) def getType(self): """Retruns the type of this parameter""" return self.type def getName(self): """Returns the name of this parameter (keyword)""" return self.name def __ge__(self, other): if self.type.name == other.type.name: return self.name.lower() >= other.name.lower() else: return self.type.name >= other.type.name def __lt__(self, other): return not self >= other def setUserData(self, data): """Set user data for this parameter.""" self.user_data = data def getUserData(self): """Retrieve the user data.""" return self.user_data def setValid(self, valid): """Set the validity of this item. An invalid item is colored red""" self.valid = valid if valid: self.setBackgroundColor(QtCore.Qt.white) else: self.setBackgroundColor(HelpedWidget.STRONG_ERROR_COLOR)
def __init__(self, ert): """ @type ert: ert.enkf.EnKFMain """ QAbstractItemModel.__init__(self) self.__ert = ert self.__icon = util.resourceIcon("ide/small/bullet_star")
def __init__(self, possible_items, label="ListEdit", help_link=""): HelpedWidget.__init__(self, label, help_link) self.__editing = True self.__valid = True self.__possible_items = possible_items self.list_edit_line = AutoCompleteLineEdit(possible_items, self) self.list_edit_line.setMinimumWidth(350) self.addWidget(self.list_edit_line) dialog_button = QToolButton(self) dialog_button.setIcon(resourceIcon("ide/small/add")) dialog_button.setIconSize(QSize(16, 16)) self.connect(dialog_button, SIGNAL('clicked()'), self.addChoice) self.addWidget(dialog_button) self.valid_color = self.list_edit_line.palette().color(self.list_edit_line.backgroundRole()) self.list_edit_line.setText("") self.__editing = False self.connect(self.list_edit_line, SIGNAL('editingFinished()'), self.validateList) self.connect(self.list_edit_line, SIGNAL('textChanged(QString)'), self.validateList) self.validateList()
def __init__(self, possible_items, label="ListEdit", help_link=""): HelpedWidget.__init__(self, label, help_link) self.__editing = True self.__valid = True self.__possible_items = possible_items self.list_edit_line = AutoCompleteLineEdit(possible_items, self) self.list_edit_line.setMinimumWidth(350) self.addWidget(self.list_edit_line) dialog_button = QToolButton(self) dialog_button.setIcon(resourceIcon("ide/small/add")) dialog_button.setIconSize(QSize(16, 16)) self.connect(dialog_button, SIGNAL('clicked()'), self.addChoice) self.addWidget(dialog_button) self.valid_color = self.list_edit_line.palette().color( self.list_edit_line.backgroundRole()) self.list_edit_line.setText("") self.__editing = False self.connect(self.list_edit_line, SIGNAL('editingFinished()'), self.validateList) self.connect(self.list_edit_line, SIGNAL('textChanged(QString)'), self.validateList) self.validateList()
def __init__(self): super(LoadResultsTool, self).__init__("Load results manually", "tools/load_manually", util.resourceIcon("ide/table_import")) self.__import_widget = None self.__dialog = None self.setVisible(False)
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(util.resourceIcon("calendar.png")) 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.setMargin(0) layout.addWidget(self._line_edit) layout.addWidget(self._calendar_button) self.setLayout(layout) self._calendar_widget.activated.connect(self.setDate)
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(util.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.setMargin(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)
def __init__(self): super(LoadResultsTool, self).__init__( "Load results manually", "tools/load_manually", util.resourceIcon("ide/table_import") ) self.__import_widget = None self.__dialog = None self.setVisible(False)
def __init__(self, model, path_label="Path", help_link=""): HelpedWidget.__init__(self, path_label, help_link) self.__editing = True self.path_line = QLineEdit() self.addWidget(self.path_line) dialog_button = QToolButton(self) dialog_button.setIcon(resourceIcon("folder")) dialog_button.setIconSize(QSize(16, 16)) self.connect(dialog_button, SIGNAL('clicked()'), self.selectDirectory) self.addWidget(dialog_button) self.valid_color = self.path_line.palette().color( self.path_line.backgroundRole()) self.path_line.setText(os.getcwd()) self.__editing = False assert isinstance(model, PathModelMixin) self.model = model model.observable().attach(PathModelMixin.PATH_CHANGED_EVENT, self.getPathFromModel) self.getPathFromModel() self.connect(self.path_line, SIGNAL('editingFinished()'), self.validatePath) self.connect(self.path_line, SIGNAL('editingFinished()'), self.contentsChanged) self.connect(self.path_line, SIGNAL('textChanged(QString)'), self.validatePath)
def __init__(self): super(ExportTool, self).__init__("Export Data", "tools/export", util.resourceIcon("ide/table_export")) self.__export_widget = None self.__dialog = None self.__exporter = None self.setEnabled(ExportKeywordModel().hasKeywords())
def __init__(self): SimulationConfigPanel.__init__(self, MultipleDataAssimilation()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) run_path_model = RunPathModel() run_path_label = ActiveLabel(run_path_model, "Runpath", "config/simulation/runpath") layout.addRow(run_path_label.getLabel(), run_path_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel(number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) target_case_format_model = TargetCaseFormatModel() self.target_case_format_field = StringBox(target_case_format_model, "Target case format", "config/simulation/target_case_format") self.target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow(self.target_case_format_field.getLabel(), self.target_case_format_field) iterated_target_case_format_model = DefaultNameFormatModel(()) iterated_target_case_format_box = StringBox(iterated_target_case_format_model, "Target case format", "config/simulation/iterated_target_case_format") iterated_target_case_format_box.setValidator(ProperNameFormatArgument()) self.option_widget = TextOrFile(self.getSimulationModel().setWeights) layout.addRow("Relative Weights:", self.option_widget) layout.addRow('Note:', QLabel("Example Custom Relative Weights: '8,4,2,1'\n" "This means MDA-ES will half the weight\n" "applied to the Observation Errors from one\n" "iteration to the next across 4 iterations.")) analysis_module_model = AnalysisModuleModel() self.analysis_module_choice = ComboChoice(analysis_module_model, "Analysis Module", "config/analysis/analysis_module") self.variables_popup_button = QToolButton() self.variables_popup_button.setIcon(util.resourceIcon("ide/small/cog_edit.png")) self.variables_popup_button.clicked.connect(self.showVariablesPopup) self.variables_popup_button.setMaximumSize(20, 20) self.variables_layout = QHBoxLayout() self.variables_layout.addWidget(self.analysis_module_choice, 0, Qt.AlignLeft) self.variables_layout.addWidget(self.variables_popup_button, 0, Qt.AlignLeft) self.variables_layout.setContentsMargins(QMargins(0,0,0,0)) self.variables_layout.addStretch() layout.addRow(self.analysis_module_choice.getLabel(), self.variables_layout) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox(active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.target_case_format_field.validationChanged.connect(self.simulationConfigurationChanged) self.active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged) self.option_widget.validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout)
def __init__(self, path, reload_function, help_tool): super(IdeTool, self).__init__("Configure", "tools/ide", util.resourceIcon("ide/widgets")) self.ide_window = None self.path = path self.reload_function = reload_function self.help_tool = help_tool
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() button = QPushButton(util.resourceIcon("ide/small/add"), "Add case to plot") button.clicked.connect(self.addCaseSelector) add_button_layout.addStretch() add_button_layout.addWidget(button) add_button_layout.addStretch() layout.addLayout(add_button_layout) self.__case_layout = QVBoxLayout() self.__case_layout.setMargin(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)
def __init__(self): QWidget.__init__(self) self.__filter_popup = FilterPopup(self) self.__filter_popup.filterSettingsChanged.connect(self.onItemChanged) layout = QVBoxLayout() self.model = DataTypeKeysListModel() self.filter_model = DataTypeProxyModel(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(util.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)
def __init__(self): QWidget.__init__(self) layout = QHBoxLayout() layout.addSpacing(10) workflow_model = WorkflowsModel() # workflow_model.observable().attach(WorkflowsModel.CURRENT_CHOICE_CHANGED_EVENT, self.showWorkflow) workflow_combo = ComboChoice(workflow_model, "Select Workflow", "run/workflow") layout.addWidget(QLabel(workflow_combo.getLabel()), 0, Qt.AlignVCenter) layout.addWidget(workflow_combo, 0, Qt.AlignVCenter) # simulation_mode_layout.addStretch() layout.addSpacing(20) self.run_button = QToolButton() self.run_button.setIconSize(QSize(32, 32)) self.run_button.setText("Start Workflow") self.run_button.setIcon(util.resourceIcon("ide/gear_in_play")) self.run_button.clicked.connect(self.startWorkflow) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) layout.addWidget(self.run_button) layout.addStretch(1) self.setLayout(layout) self.__running_workflow_dialog = None self.workflowSucceeded.connect(self.workflowFinished) self.workflowFailed.connect(self.workflowFinishedWithFail)
def __init__(self, reload_function): self.reload_function = reload_function enabled = len(WorkflowsModel().getList()) > 0 super(WorkflowsTool, self).__init__("Run Workflow", "tools/workflows", util.resourceIcon("ide/to_do_list_checked_1"), enabled)
def __init__(self, ert): """ @type ert: ert.enkf.EnKFMain """ QAbstractItemModel.__init__(self) self.__ert = ert self.__icon = util.resourceIcon("ide/small/bullet_star")
def __init__(self, model, path_label="Path", help_link=""): HelpedWidget.__init__(self, path_label, help_link) self.__editing = True self.path_line = QLineEdit() self.addWidget(self.path_line) dialog_button = QToolButton(self) dialog_button.setIcon(resourceIcon("folder")) dialog_button.setIconSize(QSize(16, 16)) self.connect(dialog_button, SIGNAL('clicked()'), self.selectDirectory) self.addWidget(dialog_button) self.valid_color = self.path_line.palette().color(self.path_line.backgroundRole()) self.path_line.setText(os.getcwd()) self.__editing = False assert isinstance(model, PathModelMixin) self.model = model model.observable().attach(PathModelMixin.PATH_CHANGED_EVENT, self.getPathFromModel) self.getPathFromModel() self.connect(self.path_line, SIGNAL('editingFinished()'), self.validatePath) self.connect(self.path_line, SIGNAL('editingFinished()'), self.contentsChanged) self.connect(self.path_line, SIGNAL('textChanged(QString)'), self.validatePath)
def __init__(self, path, reload_function, help_tool): super(IdeTool, self).__init__("Configure", "tools/ide", util.resourceIcon("ide/widgets")) self.ide_window = None self.path = path self.reload_function = reload_function self.help_tool = help_tool
def __init__(self): ''' Fills in the input panel for sensitivity study parameters. ''' SimulationConfigPanel.__init__(self, SensitivityStudy()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) runpath_model = RunPathModel() runpath_label = ActiveLabel(runpath_model, "Runpath", "config/simulation/runpath") layout.addRow(runpath_label.getLabel(), runpath_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel( number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) sensitivity_target_case_format_model = SensitivityTargetCaseFormatModel( ) self.iterated_target_case_format_field = StringBox( sensitivity_target_case_format_model, "Target case format", "config/simulation/sensitivity_target_case_format") self.iterated_target_case_format_field.setValidator( ProperNameFormatStringArgument()) layout.addRow(self.iterated_target_case_format_field.getLabel(), self.iterated_target_case_format_field) self.parameters_popup_button = QToolButton() self.parameters_popup_button.setIcon( util.resourceIcon("ide/small/cog_edit.png")) self.parameters_popup_button.clicked.connect(self.showParametersPopup) self.parameters_popup_button.setMaximumSize(20, 20) layout.addRow("Parameters:", self.parameters_popup_button) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox( active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.active_realizations_field.setValidator( RangeStringArgument(number_of_realizations_model.getValue())) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.active_realizations_field.validationChanged.connect( self.simulationConfigurationChanged) self.setLayout(layout)
def __init__(self, help_center_name, parent): super(HelpTool, self).__init__("Help", "tools/help", util.resourceIcon("ide/help"), enabled=True, checkable=True) self.setParent(parent) self.help_center_name = help_center_name if HelpTool.__help_window_instance is None: HelpTool.__help_window_instance = HelpWindow(self.help_center_name, parent=self.parent()) self.__help_window_instance.visibilityChanged.connect(self.getAction().setChecked)
def __init__(self): SimulationConfigPanel.__init__(self, MultipleDataAssimilation()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) run_path_model = RunPathModel() run_path_label = ActiveLabel(run_path_model, "Runpath", "config/simulation/runpath") layout.addRow(run_path_label.getLabel(), run_path_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel(number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) target_case_format_model = TargetCaseFormatModel() self._target_case_format_field = StringBox(target_case_format_model, "Target case format", "config/simulation/target_case_format") self._target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow(self._target_case_format_field.getLabel(), self._target_case_format_field) iterated_target_case_format_model = DefaultNameFormatModel(()) iterated_target_case_format_box = StringBox(iterated_target_case_format_model, "Target case format", "config/simulation/iterated_target_case_format") iterated_target_case_format_box.setValidator(ProperNameFormatArgument()) self._createInputForWeights(layout) analysis_module_model = AnalysisModuleModel() self._analysis_module_choice = ComboChoice(analysis_module_model, "Analysis Module", "config/analysis/analysis_module") self._variables_popup_button = QToolButton() self._variables_popup_button.setIcon(util.resourceIcon("ide/small/cog_edit.png")) self._variables_popup_button.clicked.connect(self.showVariablesPopup) self._variables_popup_button.setMaximumSize(20, 20) self._variables_layout = QHBoxLayout() self._variables_layout.addWidget(self._analysis_module_choice, 0, Qt.AlignLeft) self._variables_layout.addWidget(self._variables_popup_button, 0, Qt.AlignLeft) self._variables_layout.setContentsMargins(QMargins(0,0,0,0)) self._variables_layout.addStretch() layout.addRow(self._analysis_module_choice.getLabel(), self._variables_layout) active_realizations_model = ActiveRealizationsModel() self._active_realizations_field = StringBox(active_realizations_model, "Active realizations", "config/simulation/active_realizations") self._active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self._active_realizations_field.getLabel(), self._active_realizations_field) self._target_case_format_field.validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged) self._relative_iteration_weights_box.validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout)
def __init__(self): QToolBar.__init__(self, "PlotTools") self.setObjectName("PlotToolBar") self.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) self.__reset_scales = self.createAction( "Reset Scales", util.resourceIcon("ide/transform_scale")) self.__reset_scales.triggered.connect(self.resetScalesClicked) self.__x_min, self.__x_min_action = self.addScaler( "x_min", "X Minimum", spinner_type=CTime, select_min_time_value=True) self.__x_max, self.__x_max_action = self.addScaler("x_max", "X Maximum", spinner_type=CTime) self.__y_min, self.__y_min_action = self.addScaler( "y_min", "Y Minimum", spinner_type=float, select_min_time_value=True) self.__y_max, self.__y_max_action = self.addScaler("y_max", "Y Maximum", spinner_type=float) self.__report_step_widget = ReportStepWidget() self.__report_step_widget.reportStepTimeSelected.connect( self.reportStepChanged) self.__report_step_widget.setFontSize(PlotToolBar.FONT_SIZE) self.__report_step_widget_action = self.addWidget( self.__report_step_widget) self.addSeparator() export_action = self.createAction( "Export Plot", util.resourceIcon("ide/table_export")) export_action.triggered.connect(self.exportClicked)
def createNoSelectionsPanel(self): """The panel for no selected jobs. Enables pausing and killing the entire simulation""" self.noSimulationsPanel = QtGui.QWidget() layout = QtGui.QVBoxLayout() label = QtGui.QLabel( "Pause queue after currently running jobs are finished:") label.setWordWrap(True) layout.addWidget(label) self.pauseButton = QtGui.QToolButton(self) self.pauseButton.setIcon(resourceIcon("pause")) self.pauseButton.setCheckable(True) self.connect(self.pauseButton, QtCore.SIGNAL('clicked()'), lambda: self.ctrl.pause(self.pauseButton.isChecked())) buttonLayout = QtGui.QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(self.pauseButton) buttonLayout.addStretch(1) layout.addLayout(buttonLayout) label = QtGui.QLabel("Remove all jobs from the queue:") label.setWordWrap(True) layout.addWidget(label) self.killAllButton = QtGui.QToolButton(self) self.killAllButton.setIcon(resourceIcon("cancel")) self.connect(self.killAllButton, QtCore.SIGNAL('clicked()'), self.ctrl.killAll) buttonLayout = QtGui.QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(self.killAllButton) buttonLayout.addStretch(1) layout.addLayout(buttonLayout) self.noSimulationsPanel.setLayout(layout)
def main(argv): app = QApplication(argv) #Early so that QT is initialized before other imports app.setWindowIcon(util.resourceIcon("application/window_icon_cutout")) if len(argv) == 1: sys.stderr.write("Missing configuration file") sys.exit(1) config_file = argv[1] strict = True if not os.path.exists(config_file): print("Can not run without a configuration file.") sys.exit(1) if os.path.isdir(config_file): print("The specified configuration file is a directory!") sys.exit(1) splash = ErtSplash() splash.version = "Version %s" % Version.getVersion() splash.timestamp = Version.getBuildTime() splash.show() splash.repaint() now = time.time() ert = EnKFMain(config_file, strict=strict, verbose=False) ErtConnector.setErt(ert) window = PlotWindow(ert, None) sleep_time = 2 - (time.time() - now) if sleep_time > 0: time.sleep(sleep_time) window.show() splash.finish(window) window.activateWindow() window.raise_() finished_code = app.exec_() ert.free() sys.exit(finished_code)
def createButtons(self): """Create kill, restart and resample and restart buttons""" self.killButton = QtGui.QToolButton(self) self.killButton.setIcon(resourceIcon("cross")) self.killButton.setToolTip("Kill job") self.connect(self.killButton, QtCore.SIGNAL('clicked()'), self.ctrl.kill) self.restartButton = QtGui.QToolButton(self) self.restartButton.setIcon(resourceIcon("refresh")) self.restartButton.setToolTip("Restart job") self.connect(self.restartButton, QtCore.SIGNAL('clicked()'), lambda : self.ctrl.restart(False)) self.rrButton = QtGui.QToolButton(self) self.rrButton.setIcon(resourceIcon("refresh_resample")) self.rrButton.setToolTip("Resample and restart job") self.connect(self.rrButton, QtCore.SIGNAL('clicked()'), lambda : self.ctrl.restart(True)) buttonLayout = QtGui.QHBoxLayout() buttonLayout.addWidget(self.killButton) buttonLayout.addWidget(self.restartButton) buttonLayout.addWidget(self.rrButton) return buttonLayout
def createNoSelectionsPanel(self): """The panel for no selected jobs. Enables pausing and killing the entire simulation""" self.noSimulationsPanel = QtGui.QWidget() layout = QtGui.QVBoxLayout() label = QtGui.QLabel("Pause queue after currently running jobs are finished:") label.setWordWrap(True) layout.addWidget(label) self.pauseButton = QtGui.QToolButton(self) self.pauseButton.setIcon(resourceIcon("pause")) self.pauseButton.setCheckable(True) self.connect(self.pauseButton, QtCore.SIGNAL('clicked()'), lambda : self.ctrl.pause(self.pauseButton.isChecked())) buttonLayout = QtGui.QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(self.pauseButton) buttonLayout.addStretch(1) layout.addLayout(buttonLayout) label = QtGui.QLabel("Remove all jobs from the queue:") label.setWordWrap(True) layout.addWidget(label) self.killAllButton = QtGui.QToolButton(self) self.killAllButton.setIcon(resourceIcon("cancel")) self.connect(self.killAllButton, QtCore.SIGNAL('clicked()'), self.ctrl.killAll) buttonLayout = QtGui.QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(self.killAllButton) buttonLayout.addStretch(1) layout.addLayout(buttonLayout) self.noSimulationsPanel.setLayout(layout)
def main(argv): app = QApplication( argv) #Early so that QT is initialized before other imports app.setWindowIcon(util.resourceIcon("application/window_icon_cutout")) if len(argv) == 1: sys.stderr.write("Missing configuration file") sys.exit(1) config_file = argv[1] strict = True if not os.path.exists(config_file): print("Can not run without a configuration file.") sys.exit(1) if os.path.isdir(config_file): print("The specified configuration file is a directory!") sys.exit(1) splash = ErtSplash() splash.version = "Version %s" % Version.getVersion() splash.timestamp = Version.getBuildTime() splash.show() splash.repaint() now = time.time() ert = EnKFMain(config_file, strict=strict, verbose=False) ErtConnector.setErt(ert) window = PlotWindow(ert, None) sleep_time = 2 - (time.time() - now) if sleep_time > 0: time.sleep(sleep_time) window.show() splash.finish(window) window.activateWindow() window.raise_() finished_code = app.exec_() ert.free() sys.exit(finished_code)
def __init__(self, help_center_name, parent): super(HelpTool, self).__init__("Help", "tools/help", util.resourceIcon("ide/help"), enabled=True, checkable=True) self.setParent(parent) self.help_center_name = help_center_name if HelpTool.__help_window_instance is None: HelpTool.__help_window_instance = HelpWindow(self.help_center_name, parent=self.parent()) self.__help_window_instance.visibilityChanged.connect( self.getAction().setChecked)
def __init__(self, canvas, parent, coordinates=True): super(CustomNavigationToolbar, self).__init__(canvas, parent, coordinates) gear = util.resourceIcon("ide/cog_edit.png") customize_action = QAction(gear, "Customize", self) customize_action.setToolTip("Customize plot settings") customize_action.triggered.connect(self.customizationTriggered) for action in self.actions(): if str(action.text()).lower() == "subplots": self.removeAction(action) if str(action.text()).lower() == "customize": self.insertAction(action, customize_action) self.removeAction(action) break
def __init__(self): QWidget.__init__(self) layout = QVBoxLayout() simulation_mode_layout = QHBoxLayout() simulation_mode_layout.addSpacing(10) simulation_mode_model = SimulationModeModel() simulation_mode_model.observable().attach( SimulationModeModel.CURRENT_CHOICE_CHANGED_EVENT, self.toggleSimulationMode ) simulation_mode_combo = ComboChoice(simulation_mode_model, "Simulation mode", "run/simulation_mode") simulation_mode_layout.addWidget(QLabel(simulation_mode_combo.getLabel()), 0, Qt.AlignVCenter) simulation_mode_layout.addWidget(simulation_mode_combo, 0, Qt.AlignVCenter) # simulation_mode_layout.addStretch() 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(util.resourceIcon("ide/gear_in_play")) self.run_button.clicked.connect(self.runSimulation) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) HelpedWidget.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 = {} self.addSimulationConfigPanel(EnsembleExperimentPanel()) self.addSimulationConfigPanel(SensitivityStudyPanel()) self.addSimulationConfigPanel(EnsembleSmootherPanel()) self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel()) self.setLayout(layout)
def __init__(self): QWidget.__init__(self) layout = QVBoxLayout() add_button_layout = QHBoxLayout() export_button = QToolButton() export_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) export_button.setText("Export Plot") export_button.setIcon(util.resourceIcon("ide/small/chart_curve_go")) export_button.clicked.connect(self.exportButtonPressed.emit) add_button_layout.addStretch() add_button_layout.addWidget(export_button) add_button_layout.addStretch() layout.addLayout(add_button_layout) layout.addStretch() self.setLayout(layout)
def __init__(self, canvas, parent, coordinates=True): super(CustomNavigationToolbar, self).__init__(canvas, parent, coordinates) gear = util.resourceIcon("ide/cog_edit.png") customize_action = QAction(gear, "Customize", self) customize_action.setToolTip("Customize plot settings") customize_action.triggered.connect(self.customizationTriggered) for action in self.actions(): if str(action.text()).lower() == "subplots": self.removeAction(action) if str(action.text()).lower() == "customize": self.insertAction(action, customize_action) self.removeAction(action) break
def __init__(self): QWidget.__init__(self) layout = QVBoxLayout() simulation_mode_layout = QHBoxLayout() simulation_mode_layout.addSpacing(10) simulation_mode_model = SimulationModeModel() simulation_mode_model.observable().attach(SimulationModeModel.CURRENT_CHOICE_CHANGED_EVENT, self.toggleSimulationMode) simulation_mode_combo = ComboChoice(simulation_mode_model, "Simulation mode", "run/simulation_mode") simulation_mode_layout.addWidget(QLabel(simulation_mode_combo.getLabel()), 0, Qt.AlignVCenter) simulation_mode_layout.addWidget(simulation_mode_combo, 0, Qt.AlignVCenter) # simulation_mode_layout.addStretch() 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(util.resourceIcon("ide/gear_in_play")) self.run_button.clicked.connect(self.runSimulation) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) HelpedWidget.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 = {} self.addSimulationConfigPanel(EnsembleExperimentPanel()) self.addSimulationConfigPanel(EnsembleSmootherPanel()) self.addSimulationConfigPanel(MultipleDataAssimilationPanel()) self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel()) self.setLayout(layout)
def addCaseSelector(self, disabled=False, current_case=None): if len(self.__case_selectors_order) == 5: return widget = QWidget() layout = QHBoxLayout() layout.setMargin(0) widget.setLayout(layout) combo = QComboBox() combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon) combo.setMinimumContentsLength(20) combo.setModel(self.__model) if current_case is not None: index = 0 for item in self.__model: if item == current_case: combo.setCurrentIndex(index) break index += 1 combo.currentIndexChanged.connect(self.caseSelectionChanged.emit) layout.addWidget(combo, 1) button = QToolButton() button.setAutoRaise(True) button.setDisabled(disabled) button.setIcon(util.resourceIcon("ide/small/delete")) 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.caseSelectionChanged.emit()
def addCaseSelector(self, disabled=False, current_case=None): widget = QWidget() layout = QHBoxLayout() layout.setMargin(0) widget.setLayout(layout) combo = QComboBox() combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon) combo.setMinimumContentsLength(20) combo.setModel(self.__model) if current_case is not None: index = 0 for item in self.__model: if item == current_case: combo.setCurrentIndex(index) break index += 1 combo.currentIndexChanged.connect(self.caseSelectionChanged.emit) layout.addWidget(combo, 1) button = QToolButton() button.setAutoRaise(True) button.setDisabled(disabled) button.setIcon(util.resourceIcon("ide/small/delete")) 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()
def __init__(self): ''' Fills in the input panel for sensitivity study parameters. ''' SimulationConfigPanel.__init__(self, SensitivityStudy()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) runpath_model = RunPathModel() runpath_label = ActiveLabel(runpath_model, "Runpath", "config/simulation/runpath") layout.addRow(runpath_label.getLabel(), runpath_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel(number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) sensitivity_target_case_format_model = SensitivityTargetCaseFormatModel() self.iterated_target_case_format_field = StringBox(sensitivity_target_case_format_model, "Target case format", "config/simulation/sensitivity_target_case_format") self.iterated_target_case_format_field.setValidator(ProperNameFormatStringArgument()) layout.addRow(self.iterated_target_case_format_field.getLabel(), self.iterated_target_case_format_field) self.parameters_popup_button = QToolButton() self.parameters_popup_button.setIcon(util.resourceIcon("ide/small/cog_edit.png")) self.parameters_popup_button.clicked.connect(self.showParametersPopup) self.parameters_popup_button.setMaximumSize(20, 20) layout.addRow("Parameters:", self.parameters_popup_button) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox(active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.active_realizations_field.setValidator(RangeStringArgument(number_of_realizations_model.getValue())) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout)
def __init__(self, placeholder="yyyy-mm-dd"): QLineEdit.__init__(self) self._placeholder_text = placeholder self._active_color = self.palette().color(self.foregroundRole()) self._placeholder_active = False self._clear_button = QPushButton(self) self._clear_button.setIcon(util.resourceIcon("remove_favorite.png")) self._clear_button.setFlat(True) self._clear_button.setFocusPolicy(Qt.NoFocus) self._clear_button.setFixedSize(17, 17) self._clear_button.setCursor(Qt.ArrowCursor) self._clear_button.clicked.connect(self.clearButtonClicked) self._clear_button.setVisible(False) self.textChanged.connect(self.toggleClearButtonVisibility) self.showPlaceholder()
def __init__(self, plugin_handler): """ @type plugin_handler: PluginHandler """ enabled = len(plugin_handler) > 0 super(PluginsTool, self).__init__("Plugins", "tools/plugins", util.resourceIcon("ide/plugin"), enabled, popup_menu=True) self.__plugins = {} menu = QMenu() for plugin in plugin_handler: plugin_runner = PluginRunner(plugin) plugin_runner.setPluginFinishedCallback(self.trigger) self.__plugins[plugin] = plugin_runner plugin_action = menu.addAction(plugin.getName()) plugin_action.setToolTip(plugin.getDescription()) plugin_action.triggered.connect(plugin_runner.run) self.getAction().setMenu(menu)
def __init__(self, placeholder="yyyy-mm-dd"): QLineEdit.__init__(self) self._placeholder_text = placeholder self._active_color = self.palette().color(self.foregroundRole()) self._placeholder_active = False self._clear_button = QPushButton(self) self._clear_button.setIcon(util.resourceIcon("remove_favorite.png")) self._clear_button.setFlat(True) self._clear_button.setFocusPolicy(Qt.NoFocus) self._clear_button.setFixedSize(17, 17) self._clear_button.setCursor(Qt.ArrowCursor) self._clear_button.clicked.connect(self.clearButtonClicked) self._clear_button.setVisible(False) self.textChanged.connect(self.toggleClearButtonVisibility) self.showPlaceholder()
def __init__(self): QWidget.__init__(self) self.__filter_popup = FilterPopup(self) self.__filter_popup.filterSettingsChanged.connect(self.onItemChanged) layout = QVBoxLayout() self.model = DataTypeKeysListModel() self.filter_model = DataTypeProxyModel(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(util.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)
def __init__(self): QWidget.__init__(self) layout = QHBoxLayout() layout.addSpacing(10) workflow_model = WorkflowsModel() # workflow_model.observable().attach(WorkflowsModel.CURRENT_CHOICE_CHANGED_EVENT, self.showWorkflow) workflow_combo = ComboChoice(workflow_model, "Select Workflow", "run/workflow") layout.addWidget(QLabel(workflow_combo.getLabel()), 0, Qt.AlignVCenter) layout.addWidget(workflow_combo, 0, Qt.AlignVCenter) # simulation_mode_layout.addStretch() layout.addSpacing(20) self.run_button = QToolButton() self.run_button.setIconSize(QSize(32, 32)) self.run_button.setText("Start Workflow") self.run_button.setIcon(util.resourceIcon("ide/gear_in_play")) self.run_button.clicked.connect(self.startWorkflow) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) layout.addWidget(self.run_button) layout.addStretch(1) self.setLayout(layout) self.__running_workflow_dialog = None self.workflowSucceeded.connect(self.workflowFinished) self.workflowFailed.connect(self.workflowFinishedWithFail) self.workflowKilled.connect(self.workflowStoppedByUser) self.__workflow_runner = None """:type: WorkflowRunner"""
def __init__(self, plugin_handler): """ @type plugin_handler: PluginHandler """ enabled = len(plugin_handler) > 0 super(PluginsTool, self).__init__("Plugins", "tools/plugins", util.resourceIcon("ide/plugin"), enabled, popup_menu=True) self.__plugins = {} menu = QMenu() for plugin in plugin_handler: plugin_runner = PluginRunner(plugin) plugin_runner.setPluginFinishedCallback(self.trigger) self.__plugins[plugin] = plugin_runner plugin_action = menu.addAction(plugin.getName()) plugin_action.setToolTip(plugin.getDescription()) plugin_action.triggered.connect(plugin_runner.run) self.getAction().setMenu(menu)
def __init__(self, model, label="", help_link=""): HelpedWidget.__init__(self, "", help_link) layout = QVBoxLayout() widget = QWidget() widget.setLayout(layout) self.checkAllButton = QToolButton() self.checkAllButton.setIcon(resourceIcon("checked")) 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("notchecked")) self.uncheckAllButton.setIconSize(QSize(16, 16)) self.uncheckAllButton.setToolButtonStyle(Qt.ToolButtonIconOnly) self.uncheckAllButton.setAutoRaise(True) self.uncheckAllButton.setToolTip("Unselect all") self.list = QListWidget() self.list.setContextMenuPolicy(Qt.CustomContextMenu) self.list.setSelectionMode(QAbstractItemView.ExtendedSelection) self.search_box = SearchBox() check_button_layout = QHBoxLayout() check_button_layout.setMargin(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) layout.addWidget(self.search_box) self.addWidget(widget) self.connect(self.checkAllButton, SIGNAL('clicked()'), self.checkAll) self.connect(self.uncheckAllButton, SIGNAL('clicked()'), self.uncheckAll) self.connect(self.list, SIGNAL('itemChanged(QListWidgetItem*)'), self.itemChanged) self.search_box.filterChanged.connect(self.filterList) # self.connect(self.search_box, SIGNAL('filterChanged(str)'), self.filterList) self.connect(self.list, SIGNAL('customContextMenuRequested(QPoint)'), self.showContextMenu) assert isinstance(model, (SelectableModelMixin, ListModelMixin)) self.model = model self.model.observable().attach( SelectableModelMixin.SELECTION_CHANGED_EVENT, self.modelChanged) self.model.observable().attach(ListModelMixin.LIST_CHANGED_EVENT, self.modelChanged) self.modelChanged()
def __init__(self): QAbstractItemModel.__init__(self) self.__icon = util.resourceIcon("ide/small/bullet_star")
def __init__(self,reload_function): self.reload_function = reload_function enabled = len(WorkflowsModel().getList()) > 0 super(WorkflowsTool, self).__init__("Run Workflow", "tools/workflows", util.resourceIcon("ide/to_do_list_checked_1"), enabled)
firste_case_name = new_configuration_dialog.getCaseName() dbase_type = new_configuration_dialog.getDBaseType() num_realizations = new_configuration_dialog.getNumberOfRealizations() storage_path = new_configuration_dialog.getStoragePath() ert.enkf.enkf_main_create_new_config(enkf_config, storage_path, firste_case_name, dbase_type, num_realizations) strict = False ert.bootstrap(enkf_config, site_config=site_config, strict=strict) window.setSaveFunction(ert.save) splash.showMessage("Creating GUI...", color=QtCore.Qt.white) app.processEvents() #window.addPage("Configuration", resourceIcon("config"), ConfigPages(window)) window.addPage("Init", resourceIcon("db"), InitPanel(window)) window.addPage("Run", resourceIcon("run"), RunPanel(window)) window.addPage("Plots", resourceIcon("plot"), PlotPanel()) splash.showMessage("Communicating with ERT...", color=QtCore.Qt.white) app.processEvents() ContentModel.contentModel = ert ContentModel.updateObservers() window.show() splash.finish(window) sys.exit(app.exec_())
def __init__(self, title, parent=None): QDialog.__init__(self, parent) self.setWindowTitle(title) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setWindowFlags(self.windowFlags() & ~Qt.WindowCloseButtonHint) self.setWindowFlags(self.windowFlags() & ~Qt.WindowCancelButtonHint) self._tab_map = {} self._tab_order = [] layout = QVBoxLayout() self._tabs = QTabWidget() layout.addWidget(self._tabs) layout.setSizeConstraint(QLayout.SetFixedSize) # not resizable!!! self._button_layout = QHBoxLayout() self._reset_button = QToolButton() self._reset_button.setIcon(util.resourceIcon("update.png")) self._reset_button.setToolTip("Reset all settings back to default") self._reset_button.clicked.connect(self.resetSettings) self._undo_button = QToolButton() self._undo_button.setIcon(util.resourceIcon("undo.png")) self._undo_button.setToolTip("Undo") self._undo_button.clicked.connect(self.undoSettings) self._redo_button = QToolButton() self._redo_button.setIcon(util.resourceIcon("redo.png")) self._redo_button.setToolTip("Redo") self._redo_button.clicked.connect(self.redoSettings) self._redo_button.setEnabled(False) self._copy_button = QToolButton() self._copy_button.setIcon(util.resourceIcon("page_copy.png")) self._copy_button.setToolTip("Copy settings from another key") self._copy_button.setPopupMode(QToolButton.InstantPopup) self._copy_button.setEnabled(False) tool_menu = QMenu(self._copy_button) self._popup_list = QListWidget(tool_menu) self._popup_list.setSortingEnabled(True) self._popup_list.itemClicked.connect(self.keySelected) action = QWidgetAction(tool_menu) action.setDefaultWidget(self._popup_list) tool_menu.addAction(action) self._copy_button.setMenu(tool_menu) self._apply_button = QPushButton("Apply") self._apply_button.setToolTip("Apply the new settings") self._apply_button.clicked.connect(self.applySettings) self._apply_button.setDefault(True) self._close_button = QPushButton("Close") self._close_button.setToolTip("Hide this dialog") self._close_button.clicked.connect(self.hide) self._button_layout.addWidget(self._reset_button) self._button_layout.addStretch() self._button_layout.addWidget(self._undo_button) self._button_layout.addWidget(self._redo_button) self._button_layout.addWidget(self._copy_button) self._button_layout.addStretch() self._button_layout.addWidget(self._apply_button) self._button_layout.addWidget(self._close_button) layout.addStretch() layout.addLayout(self._button_layout) self.setLayout(layout)
def __init__(self): super(ManageCasesTool, self).__init__("Manage Cases", "tools/manage_cases", util.resourceIcon("ide/database_gear"))
def __init__(self): super(PlotTool, self).__init__("Create Plot", "tools/plot", util.resourceIcon("ide/chart_curve_add"))
def main(argv): app = QApplication(argv) #Early so that QT is initialized before other imports app.setWindowIcon(util.resourceIcon("application/window_icon_cutout")) if len(argv) == 1: config_file = QFileDialog.getOpenFileName(None, "Open Configuration File") config_file = str(config_file) if len(config_file) == 0: print("-----------------------------------------------------------------") print("-- You must supply the name of configuration file as the first --") print("-- commandline argument: --") print("-- --") print("-- bash% gert <config_file> --") print("-- --") print("-- If the configuration file does not exist, gert will create --") print("-- create a new configuration file. --") print("-----------------------------------------------------------------") sys.exit(1) else: config_file = argv[1] help_center = HelpCenter("ERT") help_center.setHelpLinkPrefix(os.getenv("ERT_SHARE_PATH") + "/gui/help/") help_center.setHelpMessageLink("welcome_to_ert") strict = True verbose = False verbose_var = os.getenv("ERT_VERBOSE", "False") lower_verbose_var = verbose_var.lower() if lower_verbose_var == "true": verbose = True if not os.path.exists(config_file): print("Trying to start new config") new_configuration_dialog = NewConfigurationDialog(config_file) success = new_configuration_dialog.exec_() if not success: print("Can not run without a configuration file.") sys.exit(1) else: config_file = new_configuration_dialog.getConfigurationPath() first_case_name = new_configuration_dialog.getCaseName() dbase_type = new_configuration_dialog.getDBaseType() num_realizations = new_configuration_dialog.getNumberOfRealizations() storage_path = new_configuration_dialog.getStoragePath() EnKFMain.createNewConfig(config_file, storage_path, first_case_name, dbase_type, num_realizations) strict = False if os.path.isdir(config_file): print("The specified configuration file is a directory!") sys.exit(1) splash = ErtSplash() splash.version = "Version %s" % Version.getVersion() splash.timestamp = Version.getBuildTime() splash.show() splash.repaint() now = time.time() ert = Ert(EnKFMain(config_file, strict=strict, verbose=verbose)) ErtConnector.setErt(ert.ert()) window = GertMainWindow() window.setWidget(SimulationPanel()) plugin_handler = PluginHandler(ert.ert(), ert.ert().getWorkflowList().getPluginJobs(), window) help_tool = HelpTool("ERT", window) window.addDock("Configuration Summary", SummaryPanel(), area=Qt.BottomDockWidgetArea) window.addTool(IdeTool(os.path.basename(config_file), ert.reloadERT, help_tool)) window.addTool(PlotTool(ert.ert())) window.addTool(ExportTool()) window.addTool(WorkflowsTool()) window.addTool(ManageCasesTool()) window.addTool(PluginsTool(plugin_handler)) window.addTool(LoadResultsTool()) window.addTool(help_tool) sleep_time = 2 - (time.time() - now) if sleep_time > 0: time.sleep(sleep_time) window.show() splash.finish(window) window.activateWindow() window.raise_() finished_code = app.exec_() ert.ert().free() sys.exit(finished_code)