DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
config_table.py
Go to the documentation of this file.
1'''
2Table for displaying DAL information
3'''
4from textual.widgets import Static, DataTable
5from textual.reactive import reactive
6
7from daqconf.cider.widgets.popups.edit_cell_screen import EditCellScreen
8from daqconf.cider.widgets.configuration_controller import ConfigurationController
9
10class 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
ConfigurationController _controller
update_table(self, config_instance)
None on_data_table_row_selected(self, DataTable.RowSelected event)