dhxpyt.message
class
Message:
14class Message: 15 def __init__(self, config: MessageConfig = None): 16 """ 17 Initializes and displays the Message widget. 18 19 :param config: (Optional) The MessageConfig object containing the message configuration. 20 """ 21 if config is None: 22 config = MessageConfig() 23 config_dict = config.to_dict() 24 # Display the message and store the returned message instance 25 self.message = js.dhx.message(None, js.JSON.parse(json.dumps(config_dict))) 26 27 def close(self) -> None: 28 """Closes the message box.""" 29 self.message.close()
Message(config: MessageConfig = None)
15 def __init__(self, config: MessageConfig = None): 16 """ 17 Initializes and displays the Message widget. 18 19 :param config: (Optional) The MessageConfig object containing the message configuration. 20 """ 21 if config is None: 22 config = MessageConfig() 23 config_dict = config.to_dict() 24 # Display the message and store the returned message instance 25 self.message = js.dhx.message(None, js.JSON.parse(json.dumps(config_dict)))
Initializes and displays the Message widget.
Parameters
- config: (Optional) The MessageConfig object containing the message configuration.
class
MessageConfig:
5class MessageConfig: 6 """ 7 Configuration class for the Message widget. 8 """ 9 def __init__(self, 10 text: str = None, 11 icon: str = None, 12 css: str = None, 13 html: str = None, 14 node: Any = None, # Could be an element or its id 15 position: str = "top-right", 16 expire: int = None): 17 """ 18 Initializes the MessageConfig. 19 20 :param text: (Optional) The text of the message box. 21 :param icon: (Optional) An icon from the used icon font. 22 :param css: (Optional) The style of the message box. 23 :param html: (Optional) The HTML content to be displayed in the message box. 24 :param node: (Optional) The container for the message box or its id. 25 :param position: (Optional) The position of the message box. 26 :param expire: (Optional) The time period of displaying the message box before it disappears, in milliseconds. 27 """ 28 self.text = text 29 self.icon = icon 30 self.css = css 31 self.html = html 32 self.node = node 33 self.position = position 34 self.expire = expire 35 36 def to_dict(self) -> Dict[str, Any]: 37 """ 38 Converts the MessageConfig into a dictionary format. 39 """ 40 config_dict = { 41 'text': self.text, 42 'icon': self.icon, 43 'css': self.css, 44 'html': self.html, 45 'node': self.node, 46 'position': self.position, 47 'expire': self.expire 48 } 49 # Remove None values 50 return {k: v for k, v in config_dict.items() if v is not None}
Configuration class for the Message widget.
MessageConfig( text: str = None, icon: str = None, css: str = None, html: str = None, node: Any = None, position: str = 'top-right', expire: int = None)
9 def __init__(self, 10 text: str = None, 11 icon: str = None, 12 css: str = None, 13 html: str = None, 14 node: Any = None, # Could be an element or its id 15 position: str = "top-right", 16 expire: int = None): 17 """ 18 Initializes the MessageConfig. 19 20 :param text: (Optional) The text of the message box. 21 :param icon: (Optional) An icon from the used icon font. 22 :param css: (Optional) The style of the message box. 23 :param html: (Optional) The HTML content to be displayed in the message box. 24 :param node: (Optional) The container for the message box or its id. 25 :param position: (Optional) The position of the message box. 26 :param expire: (Optional) The time period of displaying the message box before it disappears, in milliseconds. 27 """ 28 self.text = text 29 self.icon = icon 30 self.css = css 31 self.html = html 32 self.node = node 33 self.position = position 34 self.expire = expire
Initializes the MessageConfig.
Parameters
- text: (Optional) The text of the message box.
- icon: (Optional) An icon from the used icon font.
- css: (Optional) The style of the message box.
- html: (Optional) The HTML content to be displayed in the message box.
- node: (Optional) The container for the message box or its id.
- position: (Optional) The position of the message box.
- expire: (Optional) The time period of displaying the message box before it disappears, in milliseconds.
def
to_dict(self) -> Dict[str, Any]:
36 def to_dict(self) -> Dict[str, Any]: 37 """ 38 Converts the MessageConfig into a dictionary format. 39 """ 40 config_dict = { 41 'text': self.text, 42 'icon': self.icon, 43 'css': self.css, 44 'html': self.html, 45 'node': self.node, 46 'position': self.position, 47 'expire': self.expire 48 } 49 # Remove None values 50 return {k: v for k, v in config_dict.items() if v is not None}
Converts the MessageConfig into a dictionary format.