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

Public Member Functions

None __init__ (self, Dict[str, Dict[str, str]] button_labels, str input_message="", str|None name=None, str|None id=None, str|None classes=None)
 
 compose (self)
 
 button_actions (self, str|None button_id)
 
 input_action (self, str message)
 
 on_input_submitted (self, event)
 
 on_button_pressed (self, Button.Pressed event)
 

Protected Attributes

 _button_labels = button_labels
 
 _main_screen = self.app.get_screen("main")
 
 _config_controller = self._main_screen.query_one(ConfigurationController)
 
 _input_message = input_message
 

Detailed Description

Definition at line 12 of file file_io.py.

Constructor & Destructor Documentation

◆ __init__()

None file_io.__MenuWithButtons.__init__ ( self,
Dict[str, Dict[str, str]] button_labels,
str input_message = "",
str | None name = None,
str | None id = None,
str | None classes = None )

Reimplemented in file_io.OpenFile, file_io.RenameConfigObject, and file_io.SaveWithMessage.

Definition at line 13 of file file_io.py.

13 def __init__(self, button_labels: Dict[str, Dict[str, str]], input_message: str="", name: str | None=None, id: str | None = None, classes: str | None = None) -> None:
14 super().__init__(name=name, id=id, classes=classes)
15 """Base class for popups with N buttons and a single input field
16 """
17
18 self._button_labels = button_labels
19 self._main_screen = self.app.get_screen("main")
20 self._config_controller = self._main_screen.query_one(ConfigurationController)
21 self._input_message = input_message
22

Member Function Documentation

◆ button_actions()

file_io.__MenuWithButtons.button_actions ( self,
str| None button_id )

Reimplemented in file_io.OpenFile, file_io.RenameConfigObject, and file_io.SaveWithMessage.

Definition at line 35 of file file_io.py.

35 def button_actions(self, button_id: str| None):
36 raise NotImplementedError("button_actions should be implemented in the child class")
37

◆ compose()

file_io.__MenuWithButtons.compose ( self)
Generates interfaxce

Definition at line 23 of file file_io.py.

23 def compose(self):
24 """Generates interfaxce
25 """
26 with Container(id="save_box"):
27 yield Input(placeholder=self._input_message, classes="save_message")
28 with Horizontal(classes="buttons"):
29 # Add buttons
30 for button_text, button_properties in self._button_labels.items():
31 yield Button(button_properties["label"], id=button_text, variant=button_properties["variant"])
32 yield Button("Cancel", id="cancel", variant="error")
33 # Add input field
34

◆ input_action()

file_io.__MenuWithButtons.input_action ( self,
str message )

Reimplemented in file_io.OpenFile, file_io.RenameConfigObject, and file_io.SaveWithMessage.

Definition at line 38 of file file_io.py.

38 def input_action(self, message: str):
39 raise NotImplementedError("input_action should be implemented in the child class")
40

◆ on_button_pressed()

file_io.__MenuWithButtons.on_button_pressed ( self,
Button.Pressed event )

Definition at line 46 of file file_io.py.

46 def on_button_pressed(self, event: Button.Pressed):
47 if event.button.id != "cancel":
48 self.button_actions(event.button.id)
49
50 # Cancel button does this too but no need to check!
51 self.app.screen.dismiss(result="yay")
52

◆ on_input_submitted()

file_io.__MenuWithButtons.on_input_submitted ( self,
event )

Definition at line 41 of file file_io.py.

41 def on_input_submitted(self, event):
42 if event.value:
43 self.input_action(event.value)
44 self.app.screen.dismiss(result="yay")
45

Member Data Documentation

◆ _button_labels

file_io.__MenuWithButtons._button_labels = button_labels
protected

Definition at line 18 of file file_io.py.

◆ _config_controller

file_io.__MenuWithButtons._config_controller = self._main_screen.query_one(ConfigurationController)
protected

Definition at line 20 of file file_io.py.

◆ _input_message

file_io.__MenuWithButtons._input_message = input_message
protected

Definition at line 21 of file file_io.py.

◆ _main_screen

file_io.__MenuWithButtons._main_screen = self.app.get_screen("main")
protected

Definition at line 19 of file file_io.py.


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