DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
quit_screen.py
Go to the documentation of this file.
1from textual.widgets import Button, Label
2from textual.screen import Screen
3from textual.containers import Grid
4from textual.app import ComposeResult
5from os import environ
6
7
8class QuitScreen(Screen):
9 """Screen with a dialog to quit."""
10 css_file_path = f"{environ.get('DAQCONF_SHARE')}/config/textual_dbe/textual_css"
11
12 CSS_PATH = f"{css_file_path}/quit_screen.tcss"
13
14 def compose(self) -> ComposeResult:
15 yield Grid(
16 Label("Are you sure you want to quit? [Any unsaved changes will be lost!]", id="question"),
17 Button("Save and Quit", variant="success", id="save_quit"),
18 Button("Quit", variant="error", id="quit"),
19 Button("Cancel", variant="primary", id="cancel"),
20 id="dialog",
21 )
22
23 def on_button_pressed(self, event: Button.Pressed) -> None:
24 if event.button.id == "quit":
25 self.app.exit()
26 elif event.button.id == "save_quit":
27 main_screen = self.app.get_screen("main")
28 config_controller = main_screen.query_one("ConfigurationController")
29 config_controller.commit_configuration("Update configuration")
30 self.app.exit()
31 else:
32 self.app.pop_screen()
ComposeResult compose(self)
None on_button_pressed(self, Button.Pressed event)