DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
daqconf
python
daqconf
cider
widgets
config_table.py
Go to the documentation of this file.
1
'''
2
Table for displaying DAL information
3
'''
4
from
textual.widgets
import
Static, DataTable
5
from
textual.reactive
import
reactive
6
7
from
daqconf.cider.widgets.popups.edit_cell_screen
import
EditCellScreen
8
from
daqconf.cider.widgets.configuration_controller
import
ConfigurationController
9
10
class
ConfigTable
(Static):
11
12
# Columns in table
13
__COLS = reactive([(
"Attribute"
,
"Value"
,
"Type"
,
"Is Multivalue"
), (
""
,
""
,
""
,
""
)])
14
# Empty data table
15
_data_table = DataTable()
16
17
def
on_mount
(self):
18
"""Initialise the table object
19
"""
20
21
# Grab main controller object
22
main_screen = self.app.get_screen(
"main"
)
23
self.
_controller
: ConfigurationController = main_screen.query_one(
"ConfigurationController"
)
#type: ignore
24
25
# Add default columns
26
for
col
in
self.
__COLS
[0]:
27
28
width = 23
29
if
col==
"Value"
:
30
width = 60
31
32
self.
_data_table
.add_column(col, width=width, key=col)
33
34
# Add dummy rows
35
self.
_data_table
.add_rows(self.
__COLS
[1:])
36
37
# Some configuration to make it look "nice"
38
self.
_data_table
.fixed_rows = 0
39
self.
_data_table
.cursor_type =
"row"
40
self.
_data_table
.zebra_stripes=
True
41
42
def
compose
(self):
43
yield
self.
_data_table
44
45
def
update_table
(self, config_instance):
46
"""Updates table to display currently selected configuration object
47
48
Arguments:
49
config_instance -- DAL configuration object
50
"""
51
52
# Need to clear the table first
53
self.
_data_table
.clear()
54
55
# Get attributes for DAL
56
attributes = self.
_controller
.configuration.attributes(config_instance.className(),
True
)
57
58
# Loop over + dispaly attributes
59
for
attr_name, attr_properties
in
attributes.items():
60
attr_val = getattr(config_instance, attr_name)
61
62
# If not set we still display the default value as defined in the schema
63
if
attr_val==
''
:
64
attr_val = attr_properties[
'init-value'
]
65
66
# Dispalyattribute
67
else
:
68
self.
_data_table
.add_row(attr_name, attr_val, attr_properties[
'type'
], attr_properties[
'multivalue'
])
69
70
@property
71
def
data_table
(self)->DataTable:
72
return
self.
_data_table
73
74
def
on_data_table_row_selected
(self, event: DataTable.RowSelected) ->
None
:
75
"""Edit cell when a row is selected"""
76
self.app.push_screen(EditCellScreen(event))
77
cider.widgets.config_table.ConfigTable
Definition
config_table.py:10
cider.widgets.config_table.ConfigTable._controller
ConfigurationController _controller
Definition
config_table.py:23
cider.widgets.config_table.ConfigTable.__COLS
__COLS
Definition
config_table.py:13
cider.widgets.config_table.ConfigTable.update_table
update_table(self, config_instance)
Definition
config_table.py:45
cider.widgets.config_table.ConfigTable.on_mount
on_mount(self)
Definition
config_table.py:17
cider.widgets.config_table.ConfigTable.compose
compose(self)
Definition
config_table.py:42
cider.widgets.config_table.ConfigTable._data_table
_data_table
Definition
config_table.py:15
cider.widgets.config_table.ConfigTable.data_table
DataTable data_table(self)
Definition
config_table.py:71
cider.widgets.config_table.ConfigTable.on_data_table_row_selected
None on_data_table_row_selected(self, DataTable.RowSelected event)
Definition
config_table.py:74
Generated on
for DUNE-DAQ by
1.17.0