DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
edit_cell_screen.EditCellScreen Class Reference
Inheritance diagram for edit_cell_screen.EditCellScreen:
[legend]
Collaboration diagram for edit_cell_screen.EditCellScreen:
[legend]

Public Member Functions

None __init__ (self, Any event, str|None name=None, str|None id=None, str|None classes=None)
 
ComposeResult compose (self)
 
None on_mount (self)
 
None on_input_submitted (self, Input.Submitted event)
 
 cast_to_type_by_str (cls, str input_variable, str data_type)
 
 process_multivalue_input (cls, str input_value, str data_type)
 

Static Public Attributes

str css_file_path = f"{environ.get('DAQCONF_SHARE')}/config/textual_dbe/textual_css"
 
str CSS_PATH = f"{css_file_path}/edit_cell_layout.tcss"
 

Protected Attributes

 _data_table = main_screen.query_one("DataTable")
 
 _config_table = main_screen.query_one("ConfigTable")
 
 _row_key = event.row_key
 
 _current_row = self._data_table.get_row(event.row_key)
 
 _controller = main_screen.query_one(ConfigurationController)
 

Detailed Description

Definition at line 12 of file edit_cell_screen.py.

Constructor & Destructor Documentation

◆ __init__()

None edit_cell_screen.EditCellScreen.__init__ ( self,
Any event,
str | None name = None,
str | None id = None,
str | None classes = None )

Definition at line 17 of file edit_cell_screen.py.

18 self, event: Any, name: str | None = None, id: str | None = None, classes: str | None = None) -> None:
19 super().__init__(name=name, id=id, classes=classes)
20 """Screen which pops up when a cell is clicked in the ConfigTable
21 """
22
23 # Need to get the main screen configuration
24 main_screen = self.app.get_screen("main")
25 self._data_table = main_screen.query_one("DataTable")
26 self._config_table = main_screen.query_one("ConfigTable")
27 # self._config_table = main_screen.query_one("ConfigTable")
28
29 # Get necessary info from table
30 self._row_key = event.row_key
31 self._current_row = self._data_table.get_row(event.row_key)
32 self._controller = main_screen.query_one(ConfigurationController)
33

Member Function Documentation

◆ cast_to_type_by_str()

edit_cell_screen.EditCellScreen.cast_to_type_by_str ( cls,
str input_variable,
str data_type )
Attempt to enforce type-checking/convertion on input variable based on type-name in table. Will not work for non-built-in types

Definition at line 71 of file edit_cell_screen.py.

71 def cast_to_type_by_str(cls, input_variable: str, data_type: str):
72 """Attempt to enforce type-checking/convertion on input variable based on type-name in table. Will not work for non-built-in types
73 """
74 try:
75 return getattr(__builtins__, data_type)(input_variable)
76 except:
77 return input_variable
78

◆ compose()

ComposeResult edit_cell_screen.EditCellScreen.compose ( self)

Definition at line 34 of file edit_cell_screen.py.

34 def compose(self) -> ComposeResult:
35 with Container(id="edit_cell"):
36 yield Label(f"Enter new value for {self._current_row[0]}")
37 yield Input()
38

◆ on_input_submitted()

None edit_cell_screen.EditCellScreen.on_input_submitted ( self,
Input.Submitted event )
Applies update to the configuration object

Arguments:
    event -- Information from table row

Definition at line 47 of file edit_cell_screen.py.

47 def on_input_submitted(self, event: Input.Submitted) -> None:
48 """Applies update to the configuration object
49
50 Arguments:
51 event -- Information from table row
52 """
53 attr_name = self._current_row[0]
54 update_value = event.value
55 attr_type = self._current_row[2]
56 is_multivalue = self._current_row[3]
57
58 # Need to properly cast to list
59 if is_multivalue:
60 update_value=self.process_multivalue_input(update_value, attr_type)
61 else:
62 update_value = self.cast_to_type_by_str(update_value, attr_type)
63
64 self._controller.update_configuration(attr_name, update_value)
65 self._config_table.update_table(self._controller.current_dal)
66
67 self.app.pop_screen()
68
69

◆ on_mount()

None edit_cell_screen.EditCellScreen.on_mount ( self)
Finds the cell that was clicked and populates the input field

Definition at line 39 of file edit_cell_screen.py.

39 def on_mount(self) -> None:
40 """Finds the cell that was clicked and populates the input field
41 """
42 cell_input = self.query_one(Input)
43 # Harcoded...
44 cell_input.value = str(self._current_row[1])
45 cell_input.focus()
46

◆ process_multivalue_input()

edit_cell_screen.EditCellScreen.process_multivalue_input ( cls,
str input_value,
str data_type )
Processing required to ensure multi-variate objects are correctly placed in the table

Definition at line 80 of file edit_cell_screen.py.

80 def process_multivalue_input(cls, input_value: str, data_type: str):
81 """Processing required to ensure multi-variate objects are correctly placed in the table
82
83 """
84 # Strip brackets
85 input_value = input_value.replace("[", "")
86 input_value = input_value.replace("]", "")
87 # Strip space
88 input_value = input_value.replace(" ", "")
89 input_value = [cls.cast_to_type_by_str(i, data_type) for i in input_value.split(",")]
90
91 return input_value

Member Data Documentation

◆ _config_table

edit_cell_screen.EditCellScreen._config_table = main_screen.query_one("ConfigTable")
protected

Definition at line 26 of file edit_cell_screen.py.

◆ _controller

edit_cell_screen.EditCellScreen._controller = main_screen.query_one(ConfigurationController)
protected

Definition at line 32 of file edit_cell_screen.py.

◆ _current_row

edit_cell_screen.EditCellScreen._current_row = self._data_table.get_row(event.row_key)
protected

Definition at line 31 of file edit_cell_screen.py.

◆ _data_table

edit_cell_screen.EditCellScreen._data_table = main_screen.query_one("DataTable")
protected

Definition at line 25 of file edit_cell_screen.py.

◆ _row_key

edit_cell_screen.EditCellScreen._row_key = event.row_key
protected

Definition at line 30 of file edit_cell_screen.py.

◆ css_file_path

str edit_cell_screen.EditCellScreen.css_file_path = f"{environ.get('DAQCONF_SHARE')}/config/textual_dbe/textual_css"
static

Definition at line 13 of file edit_cell_screen.py.

◆ CSS_PATH

str edit_cell_screen.EditCellScreen.CSS_PATH = f"{css_file_path}/edit_cell_layout.tcss"
static

Definition at line 15 of file edit_cell_screen.py.


The documentation for this class was generated from the following file: