Skip to content

Commit

Permalink
Swap Qpushbuttons with QToolbuttons
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Oct 15, 2024
1 parent 3a8a0fa commit f705166
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/ert/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
QHBoxLayout,
QMainWindow,
QMenu,
QPushButton,
QToolButton,
QVBoxLayout,
QWidget,
)
Expand All @@ -38,6 +38,7 @@
QToolButton {
border-radius: 10px;
background-color: rgba(255, 255, 255, 0);
padding-top: 5px;
padding-bottom: 10px;
}
QToolButton:hover {
Expand Down Expand Up @@ -72,13 +73,14 @@ def __init__(
self.central_widget.setLayout(self.central_layout)
self.facade = LibresFacade(self.ert_config)
self.side_frame = QFrame(self)
self.side_frame.setStyleSheet("background-color: lightgray;")
self.vbox_layout = QVBoxLayout(self.side_frame)
self.side_frame.setLayout(self.vbox_layout)

self.central_panels_map: Dict[str, QWidget] = {}

self._add_sidebar_button(
"Start Simulation", QIcon("img:play_circle_outlined.svg")
"Start simulation", QIcon("img:play_circle_outlined.svg")
)

self._plot_window: Optional[PlotWindow] = None
Expand Down Expand Up @@ -176,7 +178,7 @@ def post_init(self) -> None:
self.facade.get_ensemble_size(),
)
self.central_layout.addWidget(experiment_panel)
self.central_panels_map["Start Simulation"] = experiment_panel
self.central_panels_map["Start simulation"] = experiment_panel

experiment_panel.experiment_started.connect(self.slot_add_widget)

Expand All @@ -194,18 +196,21 @@ def post_init(self) -> None:
self.help_menu.menuAction(), self.plugins_tool.get_menu()
)

def _add_sidebar_button(self, name: str, icon: QIcon) -> QPushButton:
button = QPushButton(self.side_frame)
button.setFixedSize(60, 60)
def _add_sidebar_button(self, name: str, icon: QIcon) -> QToolButton:
button = QToolButton(self.side_frame)
button.setFixedSize(70, 80)
button.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
button.setStyleSheet(BUTTON_STYLE_SHEET)
pad = 30
pad = 35
icon_size = QSize(button.size().width() - pad, button.size().height() - pad)
button.setIconSize(icon_size)
button.setIcon(icon)
button.setToolTip(name)
objname = name.replace(" ", "_")
button_text = name.replace(" ", "\n")
button.setObjectName(f"button_{objname}")
button.setText(button_text)
button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

Check failure on line 213 in src/ert/gui/main_window.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

"type[Qt]" has no attribute "ToolButtonTextUnderIcon"
self.vbox_layout.addWidget(button)

button.clicked.connect(self.select_central_widget)
Expand Down

0 comments on commit f705166

Please sign in to comment.