DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
daqconf
python
daqconf
cider
widgets
popups
add_objects.py
Go to the documentation of this file.
1
from
os
import
environ
2
3
from
textual.widgets
import
Static, Input, Select, Button
4
from
textual.containers
import
Container, Horizontal
5
from
textual.screen
import
ModalScreen
6
from
textual.app
import
ComposeResult
7
8
from
daqconf.cider.widgets.configuration_controller
import
ConfigurationController
9
from
daqconf.cider.widgets.custom_rich_log
import
RichLogWError
10
11
class
AddNewObject
(Static):
12
def
compose
(self):
13
# Standard copy/paste
14
self.
_main_screen
= self.app.get_screen(
"main"
)
15
self.
_config_controller
: ConfigurationController = self.
_main_screen
.query_one(ConfigurationController)
16
17
with
Container(id=
"object_add_box"
):
18
with
Horizontal(id=
"select"
):
19
yield
Input(id=
"uid_input"
, placeholder=
"Object ID"
)
20
yield
Select([(c, c)
for
c
in
self.
_config_controller
.get_list_of_classes()],
21
id=
"class_select"
, allow_blank=
True
)
22
# with Horizontal(classes="buttons"):
23
# Add buttons
24
yield
Button(
"Add Object"
, id=
"add_obj"
, variant=
"success"
)
25
yield
Button(
"Cancel"
, id=
"cancel"
, variant=
"error"
)
26
27
def
on_button_pressed
(self, event: Button.Pressed):
28
if
event.button.id==
"add_obj"
:
29
self.
add_object
()
30
else
:
31
self.app.screen.dismiss()
32
33
def
add_object
(self):
34
input = self.query_one(Input)
35
selection = self.query_one(Select)
36
37
uid = input.value
38
config_class = selection.value
39
40
if
uid
and
not
selection.is_blank():
41
self.
_config_controller
.add_new_conf_obj(config_class, uid)
42
43
self.
dismiss_and_update
()
44
45
def
dismiss_and_update
(self):
46
selection_menu = self.
_main_screen
.query_exactly_one(
"SelectionPanel"
)
47
selection_menu.refresh(recompose=
True
)
48
selection_menu.restore_menu_state()
49
self.app.screen.dismiss()
50
51
52
class
AddNewObjectScreen
(ModalScreen[bool]):
53
css_file_path = f
"{environ.get('DAQCONF_SHARE')}/config/textual_dbe/textual_css"
54
55
CSS_PATH = f
"{css_file_path}/add_object_layout.tcss"
56
"""
57
Splash screen for adding configuration
58
"""
59
60
def
compose
(self)->ComposeResult:
61
yield
AddNewObject
()
62
63
def
on_mount
(self) -> None:
64
message_box = self.query_one(AddNewObject)
65
message_box.focus()
66
add_objects.AddNewObjectScreen
Definition
add_objects.py:52
add_objects.AddNewObjectScreen.compose
ComposeResult compose(self)
Definition
add_objects.py:60
add_objects.AddNewObjectScreen.on_mount
None on_mount(self)
Definition
add_objects.py:63
add_objects.AddNewObject
Definition
add_objects.py:11
add_objects.AddNewObject.on_button_pressed
on_button_pressed(self, Button.Pressed event)
Definition
add_objects.py:27
add_objects.AddNewObject._config_controller
ConfigurationController _config_controller
Definition
add_objects.py:15
add_objects.AddNewObject.dismiss_and_update
dismiss_and_update(self)
Definition
add_objects.py:45
add_objects.AddNewObject.add_object
add_object(self)
Definition
add_objects.py:33
add_objects.AddNewObject._main_screen
_main_screen
Definition
add_objects.py:14
add_objects.AddNewObject.compose
compose(self)
Definition
add_objects.py:12
Generated on
for DUNE-DAQ by
1.17.0