dhxpyt.popup
class
Popup:
14class Popup: 15 def __init__(self, config: PopupConfig = None): 16 """ 17 Initializes the Popup widget. 18 19 :param config: (Optional) The PopupConfig object containing the popup configuration. 20 """ 21 if config is None: 22 config = PopupConfig() 23 config_dict = config.to_dict() 24 # Create the Popup instance 25 self.popup = js.dhx.Popup.new(None, js.JSON.parse(json.dumps(config_dict))) 26 27 """ Popup API Functions """ 28 29 def attach(self, name: Union[str, Any], config: Dict[str, Any] = None) -> Any: 30 """ 31 Attaches a DHTMLX component to the Popup. 32 33 :param name: The name or object of a component. 34 :param config: (Optional) The configuration settings of a component. 35 :return: The object of the attached component. 36 """ 37 if config is None: 38 config = {} 39 component = self.popup.attach(name, js.JSON.parse(json.dumps(config))) 40 return component 41 42 def attach_html(self, html: str) -> None: 43 """ 44 Adds HTML content into the Popup. 45 46 :param html: An HTML content to be added into the popup. 47 """ 48 self.popup.attachHTML(html) 49 50 def destructor(self) -> None: 51 """ 52 Removes the Popup instance and releases occupied resources. 53 """ 54 self.popup.destructor() 55 56 def get_container(self) -> Any: 57 """ 58 Returns the HTML element of the Popup. 59 60 :return: The HTML element. 61 """ 62 return self.popup.getContainer() 63 64 def get_widget(self) -> Any: 65 """ 66 Returns the widget attached to the Popup. 67 68 :return: The widget attached to the Popup. 69 """ 70 return self.popup.getWidget() 71 72 def hide(self) -> None: 73 """ 74 Hides the Popup. 75 """ 76 self.popup.hide() 77 78 def is_visible(self) -> bool: 79 """ 80 Checks whether the Popup is visible. 81 82 :return: True if the Popup is visible; otherwise, False. 83 """ 84 return self.popup.isVisible() 85 86 def paint(self) -> None: 87 """ 88 Repaints the Popup on the page. 89 """ 90 self.popup.paint() 91 92 def show(self, node: Any, config: PopupShowConfig = None) -> None: 93 """ 94 Shows the Popup. 95 96 :param node: The container to place the Popup in. 97 :param config: (Optional) The configuration object of the Popup. 98 """ 99 if config is None: 100 config = {} 101 self.popup.show(node, js.JSON.parse(json.dumps(config))) 102 103 """ Popup Event Handlers """ 104 105 def add_event_handler(self, event_name: str, handler: Callable) -> None: 106 """ 107 Adds an event handler for the specified event. 108 109 :param event_name: The name of the event. 110 :param handler: The handler function to attach. 111 """ 112 event_proxy = create_proxy(handler) 113 self.popup.events.on(event_name, event_proxy) 114 115 def on_after_hide(self, handler: Callable[[Any], None]) -> None: 116 """ 117 Fires after the Popup is hidden. 118 119 :param handler: The handler function with parameter e (Event). 120 """ 121 self.add_event_handler('afterHide', handler) 122 123 def on_after_show(self, handler: Callable[[Any], None]) -> None: 124 """ 125 Fires after the Popup is shown. 126 127 :param handler: The handler function with parameter node (HTMLElement). 128 """ 129 self.add_event_handler('afterShow', handler) 130 131 def on_before_hide(self, handler: Callable[[bool, Any], Union[bool, None]]) -> None: 132 """ 133 Fires before the Popup is hidden. 134 135 :param handler: The handler function with parameters fromOuterClick (bool), e (Event). 136 """ 137 def event_handler(fromOuterClick, e): 138 result = handler(fromOuterClick, e) 139 if result is False: 140 return js.Boolean(False) 141 self.popup.events.on('beforeHide', create_proxy(event_handler)) 142 143 def on_before_show(self, handler: Callable[[Any], Union[bool, None]]) -> None: 144 """ 145 Fires before the Popup is shown. 146 147 :param handler: The handler function with parameter node (HTMLElement). 148 """ 149 def event_handler(node): 150 result = handler(node) 151 if result is False: 152 return js.Boolean(False) 153 self.popup.events.on('beforeShow', create_proxy(event_handler)) 154 155 def on_click(self, handler: Callable[[Any], None]) -> None: 156 """ 157 Fires on clicking the Popup. 158 159 :param handler: The handler function with parameter e (Event). 160 """ 161 self.add_event_handler('click', handler)
Popup(config: PopupConfig = None)
15 def __init__(self, config: PopupConfig = None): 16 """ 17 Initializes the Popup widget. 18 19 :param config: (Optional) The PopupConfig object containing the popup configuration. 20 """ 21 if config is None: 22 config = PopupConfig() 23 config_dict = config.to_dict() 24 # Create the Popup instance 25 self.popup = js.dhx.Popup.new(None, js.JSON.parse(json.dumps(config_dict)))
Initializes the Popup widget.
Parameters
- config: (Optional) The PopupConfig object containing the popup configuration.
def
attach(self, name: Union[str, Any], config: Dict[str, Any] = None) -> Any:
29 def attach(self, name: Union[str, Any], config: Dict[str, Any] = None) -> Any: 30 """ 31 Attaches a DHTMLX component to the Popup. 32 33 :param name: The name or object of a component. 34 :param config: (Optional) The configuration settings of a component. 35 :return: The object of the attached component. 36 """ 37 if config is None: 38 config = {} 39 component = self.popup.attach(name, js.JSON.parse(json.dumps(config))) 40 return component
Attaches a DHTMLX component to the Popup.
Parameters
- name: The name or object of a component.
- config: (Optional) The configuration settings of a component.
Returns
The object of the attached component.
def
attach_html(self, html: str) -> None:
42 def attach_html(self, html: str) -> None: 43 """ 44 Adds HTML content into the Popup. 45 46 :param html: An HTML content to be added into the popup. 47 """ 48 self.popup.attachHTML(html)
Adds HTML content into the Popup.
Parameters
- html: An HTML content to be added into the popup.
def
destructor(self) -> None:
50 def destructor(self) -> None: 51 """ 52 Removes the Popup instance and releases occupied resources. 53 """ 54 self.popup.destructor()
Removes the Popup instance and releases occupied resources.
def
get_container(self) -> Any:
56 def get_container(self) -> Any: 57 """ 58 Returns the HTML element of the Popup. 59 60 :return: The HTML element. 61 """ 62 return self.popup.getContainer()
Returns the HTML element of the Popup.
Returns
The HTML element.
def
get_widget(self) -> Any:
64 def get_widget(self) -> Any: 65 """ 66 Returns the widget attached to the Popup. 67 68 :return: The widget attached to the Popup. 69 """ 70 return self.popup.getWidget()
Returns the widget attached to the Popup.
Returns
The widget attached to the Popup.
def
is_visible(self) -> bool:
78 def is_visible(self) -> bool: 79 """ 80 Checks whether the Popup is visible. 81 82 :return: True if the Popup is visible; otherwise, False. 83 """ 84 return self.popup.isVisible()
Checks whether the Popup is visible.
Returns
True if the Popup is visible; otherwise, False.
def
show( self, node: Any, config: dhxpyt.popup.popup_config.PopupShowConfig = None) -> None:
92 def show(self, node: Any, config: PopupShowConfig = None) -> None: 93 """ 94 Shows the Popup. 95 96 :param node: The container to place the Popup in. 97 :param config: (Optional) The configuration object of the Popup. 98 """ 99 if config is None: 100 config = {} 101 self.popup.show(node, js.JSON.parse(json.dumps(config)))
Shows the Popup.
Parameters
- node: The container to place the Popup in.
- config: (Optional) The configuration object of the Popup.
def
add_event_handler(self, event_name: str, handler: Callable) -> None:
105 def add_event_handler(self, event_name: str, handler: Callable) -> None: 106 """ 107 Adds an event handler for the specified event. 108 109 :param event_name: The name of the event. 110 :param handler: The handler function to attach. 111 """ 112 event_proxy = create_proxy(handler) 113 self.popup.events.on(event_name, event_proxy)
Adds an event handler for the specified event.
Parameters
- event_name: The name of the event.
- handler: The handler function to attach.
def
on_after_hide(self, handler: Callable[[Any], NoneType]) -> None:
115 def on_after_hide(self, handler: Callable[[Any], None]) -> None: 116 """ 117 Fires after the Popup is hidden. 118 119 :param handler: The handler function with parameter e (Event). 120 """ 121 self.add_event_handler('afterHide', handler)
Fires after the Popup is hidden.
Parameters
- handler: The handler function with parameter e (Event).
def
on_after_show(self, handler: Callable[[Any], NoneType]) -> None:
123 def on_after_show(self, handler: Callable[[Any], None]) -> None: 124 """ 125 Fires after the Popup is shown. 126 127 :param handler: The handler function with parameter node (HTMLElement). 128 """ 129 self.add_event_handler('afterShow', handler)
Fires after the Popup is shown.
Parameters
- handler: The handler function with parameter node (HTMLElement).
def
on_before_hide(self, handler: Callable[[bool, Any], Optional[bool]]) -> None:
131 def on_before_hide(self, handler: Callable[[bool, Any], Union[bool, None]]) -> None: 132 """ 133 Fires before the Popup is hidden. 134 135 :param handler: The handler function with parameters fromOuterClick (bool), e (Event). 136 """ 137 def event_handler(fromOuterClick, e): 138 result = handler(fromOuterClick, e) 139 if result is False: 140 return js.Boolean(False) 141 self.popup.events.on('beforeHide', create_proxy(event_handler))
Fires before the Popup is hidden.
Parameters
- handler: The handler function with parameters fromOuterClick (bool), e (Event).
def
on_before_show(self, handler: Callable[[Any], Optional[bool]]) -> None:
143 def on_before_show(self, handler: Callable[[Any], Union[bool, None]]) -> None: 144 """ 145 Fires before the Popup is shown. 146 147 :param handler: The handler function with parameter node (HTMLElement). 148 """ 149 def event_handler(node): 150 result = handler(node) 151 if result is False: 152 return js.Boolean(False) 153 self.popup.events.on('beforeShow', create_proxy(event_handler))
Fires before the Popup is shown.
Parameters
- handler: The handler function with parameter node (HTMLElement).
def
on_click(self, handler: Callable[[Any], NoneType]) -> None:
155 def on_click(self, handler: Callable[[Any], None]) -> None: 156 """ 157 Fires on clicking the Popup. 158 159 :param handler: The handler function with parameter e (Event). 160 """ 161 self.add_event_handler('click', handler)
Fires on clicking the Popup.
Parameters
- handler: The handler function with parameter e (Event).
class
PopupConfig:
6class PopupConfig: 7 """ 8 Configuration class for the Popup widget. 9 """ 10 def __init__(self, 11 css: str = None): 12 """ 13 Initializes the PopupConfig. 14 15 :param css: (Optional) Adds style classes for the component. 16 """ 17 self.css = css 18 19 def to_dict(self) -> Dict[str, Any]: 20 """ 21 Converts the PopupConfig into a dictionary format. 22 """ 23 config_dict = { 24 'css': self.css 25 } 26 # Remove None values 27 return {k: v for k, v in config_dict.items() if v is not None}
Configuration class for the Popup widget.
PopupConfig(css: str = None)
10 def __init__(self, 11 css: str = None): 12 """ 13 Initializes the PopupConfig. 14 15 :param css: (Optional) Adds style classes for the component. 16 """ 17 self.css = css
Initializes the PopupConfig.
Parameters
- css: (Optional) Adds style classes for the component.
def
to_dict(self) -> Dict[str, Any]:
19 def to_dict(self) -> Dict[str, Any]: 20 """ 21 Converts the PopupConfig into a dictionary format. 22 """ 23 config_dict = { 24 'css': self.css 25 } 26 # Remove None values 27 return {k: v for k, v in config_dict.items() if v is not None}
Converts the PopupConfig into a dictionary format.