DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
delete_object_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
7from daqconf.cider.widgets.configuration_controller import ConfigurationController
8
10
11 css_file_path = f"{environ.get('DAQCONF_SHARE')}/config/textual_dbe/textual_css"
12
13 CSS_PATH = f"{css_file_path}/delete_screen.tcss"
14
15
16 def compose(self) -> ComposeResult:
17 self._main_screen = self.app.get_screen("main")
18 self._config_controller: ConfigurationController = self._main_screen.query_one(ConfigurationController)
19
20 selected_obj = getattr(self._config_controller.current_dal, "id")
21
22 yield Grid(
23
24 Label(f"Are you sure you want to delete {selected_obj}?]", id="question"),
25 Button("Delete", variant="success", id="delete"),
26 Button("Cancel", variant="primary", id="cancel"),
27 id="dialog",
28 )
29
30 # Need to move this somewhere
32 selection_menu = self._main_screen.query_exactly_one("SelectionPanel")
33 selection_menu.refresh(recompose=True)
34 selection_menu.restore_menu_state()
35 self.app.screen.dismiss()
36
37 def on_button_pressed(self, event: Button.Pressed) -> None:
38 if event.button.id == "delete":
39 try:
40 self._config_controller.destroy_current_object()
41 except Exception as e:
42 self._main_screen.query_one("RichLogWError").write_error(e)
44 else:
45 self.app.pop_screen()
None on_button_pressed(self, Button.Pressed event)