Skip to content

Commit daf8bba

Browse files
committed
Add proof of concept qmenu-button
1 parent 297b396 commit daf8bba

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/ert/gui/main_window.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
QFrame,
1212
QHBoxLayout,
1313
QMainWindow,
14+
QMenu,
1415
QPushButton,
1516
QVBoxLayout,
1617
)
@@ -44,6 +45,21 @@
4445
background-color: rgba(255, 255, 255, 200);
4546
}
4647
"""
48+
MENU_ITEM_STYLE_SHEET: str = """
49+
QMenu:item {
50+
border: 2px solid darkgrey;
51+
border-radius: 5px;
52+
background-color: rgba(255, 255, 255, 0);
53+
padding-top:5px;
54+
padding-left: 5px;
55+
background: rgba(0,0,0,0);
56+
font-weight: bold;
57+
font-size: 13px;
58+
}
59+
QMenu:item:selected {
60+
background-color: rgba(255, 255, 255, 200);
61+
}
62+
"""
4763

4864

4965
class ErtMainWindow(QMainWindow):
@@ -64,6 +80,8 @@ def __init__(
6480
self.log_handler = log_handler
6581

6682
self.setWindowTitle(f"ERT - {config_file} - {find_ert_info()}")
83+
self.central_panels = []
84+
self.central_panels_index = 0
6785

6886
self.plugin_manager = plugin_manager
6987
self.central_widget = QFrame(self)
@@ -79,7 +97,6 @@ def __init__(
7997
self.side_frame.setLayout(self.vbox_layout)
8098

8199
self.add_experiment_button()
82-
self.central_panels = []
83100
self._plot_tool = PlotTool(self.config_file, self)
84101
self._create_sidebar_button(self._plot_tool)
85102

@@ -133,6 +150,8 @@ def _create_sidebar_button(self, tool: Optional[Tool] = None) -> QPushButton:
133150
button.setToolTip(tool.getName())
134151
button.clicked.connect(tool.trigger)
135152
self.vbox_layout.addWidget(button)
153+
button.setProperty("INDEX", self.central_panels_index)
154+
self.central_panels_index += 1
136155
return button
137156

138157
def add_experiment_button(self) -> None:
@@ -141,6 +160,15 @@ def add_experiment_button(self) -> None:
141160
button.setToolTip("Start Simulation")
142161
button.clicked.connect(self.toggle_visibility)
143162

163+
menu = QMenu()
164+
menu.addAction("Single Test Run")
165+
menu.addAction("Ensemble Experiment")
166+
menu.addAction("Manual Update")
167+
menu.addAction("ES MDA")
168+
menu.addAction("Ensemble Smoother")
169+
menu.setStyleSheet(MENU_ITEM_STYLE_SHEET)
170+
button.setMenu(menu)
171+
144172
def toggle_visibility(self) -> None:
145173
for panel in self.central_panels:
146174
panel.show()

0 commit comments

Comments
 (0)