Skip to content

Commit

Permalink
Fixup: reverted windowflags to be the same as before. some minor touc…
Browse files Browse the repository at this point in the history
…hups
  • Loading branch information
JHolba committed Jan 12, 2025
1 parent 68ddb7c commit 8d920b9
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 40 deletions.
9 changes: 2 additions & 7 deletions src/ert/gui/ertwidgets/listeditbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ def textUnderCursor(self) -> str:

def keyPressEvent(self, arg__1: QKeyEvent) -> None:
popup = self._completer.popup()
if (
popup is not None
and popup.isVisible()
and arg__1 is not None
and arg__1.key() in self.__keysToIgnore
):
if popup and popup.isVisible() and arg__1.key() in self.__keysToIgnore:
arg__1.ignore()
return

Expand All @@ -66,7 +61,7 @@ def keyPressEvent(self, arg__1: QKeyEvent) -> None:
completion_prefix = self.textUnderCursor()
if completion_prefix != self._completer.completionPrefix():
self.__updateCompleterPopupItems(completion_prefix)
if arg__1 is not None and len(arg__1.text()) > 0 and len(completion_prefix) > 0:
if len(arg__1.text()) > 0 and len(completion_prefix) > 0:
self._completer.complete()
if popup is not None and len(completion_prefix) == 0:
popup.hide()
Expand Down
10 changes: 2 additions & 8 deletions src/ert/gui/model/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class _NodeBase(ABC):
_index: int | None = None


def _repr(node: _Node) -> str:
def _repr(node: RootNode | IterNode | RealNode | ForwardModelStepNode) -> str:
parent = "no " if node.parent is None else ""
children = "no " if not node.children else f"{len(node.children)} "
return f"Node<{type(node).__name__}>@{node.id_} with {parent}parent and {children}children"


def _row(node: _Node) -> int:
def _row(node: RootNode | IterNode | RealNode | ForwardModelStepNode) -> int:
if not node._index:
if node.parent:
node._index = list(node.parent.children.keys()).index(node.id_)
Expand Down Expand Up @@ -105,14 +105,8 @@ class ForwardModelStepNode(_NodeBase):
data: FMStepSnapshot = field(default_factory=lambda: FMStepSnapshot()) # noqa: PLW0108
children: dict[str, None] = field(default_factory=dict)

def add_child(self, _: _NodeBase) -> None:
raise RuntimeError(f"Can not add children to {self.__class__.__name__}")

def row(self) -> int:
return _row(self)

def __repr__(self) -> str:
return _repr(self)


_Node = RootNode | IterNode | RealNode | ForwardModelStepNode
6 changes: 2 additions & 4 deletions src/ert/gui/model/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def data(
if isinstance(node, ForwardModelStepNode):
return self._fm_step_data(index, node, Qt.ItemDataRole(role))
if isinstance(node, RealNode):
return self._real_data(index, node, role)
return self._real_data(node, role)

if role == Qt.ItemDataRole.DisplayRole:
if index.column() == 0:
Expand Down Expand Up @@ -383,9 +383,7 @@ def data(
return None

@staticmethod
def _real_data(
_: QModelIndex | QPersistentModelIndex, node: RealNode, role: int
) -> Any:
def _real_data(node: RealNode, role: int) -> Any:
if role == FMStepColorHint:
total_count = len(node.data.fm_step_status_color_by_id)
finished_count = sum(
Expand Down
2 changes: 1 addition & 1 deletion src/ert/gui/simulation/experiment_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def run_experiment(self) -> None:
QMessageBox.warning(
self,
"ERROR: Failed to create experiment",
(str(e)),
str(e),
QMessageBox.StandardButton.Ok,
)
return
Expand Down
21 changes: 10 additions & 11 deletions src/ert/gui/simulation/run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,15 @@ def _fm_step_clicked(self, index: QModelIndex) -> None:
error_dialog.exec()

def mouseMoveEvent(self, event: QMouseEvent) -> None:
if event:
index = self.indexAt(event.pos())
if index.isValid():
data_name = FM_STEP_COLUMNS[index.column()]
if data_name in {ids.STDOUT, ids.STDERR} and file_has_content(
index.data(FileRole)
):
self.setCursor(Qt.CursorShape.PointingHandCursor)
else:
self.setCursor(Qt.CursorShape.ArrowCursor)
index = self.indexAt(event.pos())
if index.isValid():
data_name = FM_STEP_COLUMNS[index.column()]
if data_name in {ids.STDOUT, ids.STDERR} and file_has_content(
index.data(FileRole)
):
self.setCursor(Qt.CursorShape.PointingHandCursor)
else:
self.setCursor(Qt.CursorShape.ArrowCursor)

return super().mouseMoveEvent(event)

Expand All @@ -181,7 +180,7 @@ def __init__(
QFrame.__init__(self, parent)
self.output_path = output_path
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
self.setWindowFlag(Qt.WindowType.Window, True)
self.setWindowFlags(Qt.WindowType.Window)
self.setWindowFlag(Qt.WindowType.WindowContextHelpButtonHint, False)
self.setWindowTitle(f"Experiment - {config_file} {find_ert_info()}")

Expand Down
15 changes: 6 additions & 9 deletions src/ert/gui/tools/plot/customize/limits_customization_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,14 @@ def getValue(self, axis_name: str | None) -> float | int | date | None:
input_ = self._inputs[axis_name]
result: float | int | date | None = None
if issubclass(type(input_), QLineEdit) or issubclass(type(input_), QLabel):
input_ = cast(QLineEdit | QLabel, input_)
if axis_name in LimitsStack.FLOAT_AXIS:
try:
try:
input_ = cast(QLineEdit | QLabel, input_)
if axis_name in LimitsStack.FLOAT_AXIS:
result = float(input_.text())
except ValueError:
result = None
elif axis_name in LimitsStack.INT_AXIS:
try:
elif axis_name in LimitsStack.INT_AXIS:
result = int(input_.text())
except ValueError:
result = None
except ValueError:
result = None
elif axis_name == PlotContext.DATE_AXIS and type(input_) is CustomDateEdit:
result = input_.date()

Expand Down
1 change: 1 addition & 0 deletions tests/ert/ui_tests/gui/test_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from ert.gui.ertwidgets.create_experiment_dialog import CreateExperimentDialog
from ert.gui.ertwidgets.ensembleselector import EnsembleSelector
from ert.gui.main import ErtMainWindow, GUILogHandler, _setup_main_window
from ert.gui.main_window import SidebarToolButton
from ert.gui.simulation.experiment_panel import ExperimentPanel
from ert.gui.simulation.run_dialog import RunDialog
from ert.gui.suggestor import Suggestor
Expand Down

0 comments on commit 8d920b9

Please sign in to comment.