dhxpyt.listbox

1from .listbox import Listbox
2from .listbox_config import ListboxConfig
3
4__all__ = ["Listbox", "ListboxConfig"]
class Listbox:
 14class Listbox:
 15    def __init__(self, config: ListboxConfig = None, widget_parent: str = None):
 16        """
 17        Initializes the ListBox widget.
 18
 19        :param config: (Optional) The ListBoxConfig object containing the list configuration.
 20        :param widget_parent: (Optional) The ID of the HTML element where the list will be attached.
 21        """
 22        if config is None:
 23            config = ListboxConfig()
 24        config_dict = config.to_dict()
 25        self.listbox = js.dhx.List.new(widget_parent, js.JSON.parse(json.dumps(config_dict)))
 26
 27    """ ListBox API Functions """
 28
 29    def destructor(self) -> None:
 30        """Destroys the ListBox instance and releases resources."""
 31        self.listbox.destructor()
 32
 33    def edit_item(self, item_id: Union[str, int]) -> None:
 34        """Enables editing of an item."""
 35        self.listbox.editItem(item_id)
 36
 37    def get_focus(self) -> Union[str, int]:
 38        """Returns the ID of the item in focus."""
 39        return self.listbox.getFocus()
 40
 41    def get_focus_item(self) -> Dict[str, Any]:
 42        """Returns the object of the item in focus."""
 43        item = self.listbox.getFocusItem()
 44        return item.to_py() if item else None
 45
 46    def paint(self) -> None:
 47        """Repaints the list on the page."""
 48        self.listbox.paint()
 49
 50    def reset_focus(self) -> None:
 51        """Resets focus and moves the scroll to the beginning of the list."""
 52        self.listbox.resetFocus()
 53
 54    def set_focus(self, item_id: Union[str, int]) -> None:
 55        """Sets focus to an item by its ID and moves the scroll to it."""
 56        self.listbox.setFocus(item_id)
 57
 58    """ ListBox Event Handlers """
 59
 60    def add_event_handler(self, event_name: str, handler: Callable) -> None:
 61        """Adds an event handler for the specified event."""
 62        event_proxy = create_proxy(handler)
 63        self.listbox.events.on(event_name, event_proxy)
 64
 65    def on_after_drag(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
 66        """Fires after dragging of an item is finished."""
 67        def event_handler(data, events):
 68            handler(data.to_py(), events)
 69        self.listbox.events.on('afterDrag', create_proxy(event_handler))
 70
 71    def on_after_drop(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
 72        """Fires before the user has finished dragging of an item but after the mouse button is released."""
 73        def event_handler(data, events):
 74            handler(data.to_py(), events)
 75        self.listbox.events.on('afterDrop', create_proxy(event_handler))
 76
 77    def on_after_edit_end(self, handler: Callable[[str, Union[str, int]], None]) -> None:
 78        """Fires after editing of an item is ended."""
 79        self.add_event_handler('afterEditEnd', handler)
 80
 81    def on_after_edit_start(self, handler: Callable[[Union[str, int]], None]) -> None:
 82        """Fires after editing of an item has started."""
 83        self.add_event_handler('afterEditStart', handler)
 84
 85    def on_before_drag(self, handler: Callable[[Dict[str, Any], Any], Union[bool, None]]) -> None:
 86        """Fires before dragging of an item has started."""
 87        def event_handler(data, events):
 88            result = handler(data.to_py(), events)
 89            if result is False:
 90                return js.Boolean(False)
 91        self.listbox.events.on('beforeDrag', create_proxy(event_handler))
 92
 93    def on_before_drop(self, handler: Callable[[Dict[str, Any], Any], Union[bool, None]]) -> None:
 94        """Fires before the user has finished dragging of an item and released the mouse button."""
 95        def event_handler(data, events):
 96            result = handler(data.to_py(), events)
 97            if result is False:
 98                return js.Boolean(False)
 99        self.listbox.events.on('beforeDrop', create_proxy(event_handler))
100
101    def on_before_edit_end(self, handler: Callable[[str, Union[str, int]], Union[bool, None]]) -> None:
102        """Fires before editing of an item is ended."""
103        def event_handler(value, id):
104            result = handler(value, id)
105            if result is False:
106                return js.Boolean(False)
107        self.listbox.events.on('beforeEditEnd', create_proxy(event_handler))
108
109    def on_before_edit_start(self, handler: Callable[[Union[str, int]], Union[bool, None]]) -> None:
110        """Fires before editing of an item has started."""
111        def event_handler(id):
112            result = handler(id)
113            if result is False:
114                return js.Boolean(False)
115        self.listbox.events.on('beforeEditStart', create_proxy(event_handler))
116
117    def on_cancel_drop(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
118        """Fires on moving a mouse pointer out of item's borders while dragging the item."""
119        def event_handler(data, events):
120            handler(data.to_py(), events)
121        self.listbox.events.on('cancelDrop', create_proxy(event_handler))
122
123    def on_can_drop(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
124        """Fires when a dragged item is over a target item."""
125        def event_handler(data, events):
126            handler(data.to_py(), events)
127        self.listbox.events.on('canDrop', create_proxy(event_handler))
128
129    def on_click(self, handler: Callable[[Union[str, int], Any], None]) -> None:
130        """Fires on clicking an item."""
131        self.add_event_handler('click', handler)
132
133    def on_double_click(self, handler: Callable[[Union[str, int], Any], None]) -> None:
134        """Fires on double-clicking an item."""
135        self.add_event_handler('doubleClick', handler)
136
137    def on_drag_in(self, handler: Callable[[Dict[str, Any], Any], Union[bool, None]]) -> None:
138        """Fires when an item is dragged to another potential target."""
139        def event_handler(data, events):
140            result = handler(data.to_py(), events)
141            if result is False:
142                return js.Boolean(False)
143        self.listbox.events.on('dragIn', create_proxy(event_handler))
144
145    def on_drag_out(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
146        """Fires when an item is dragged out of a potential target."""
147        def event_handler(data, events):
148            handler(data.to_py(), events)
149        self.listbox.events.on('dragOut', create_proxy(event_handler))
150
151    def on_drag_start(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
152        """Fires when dragging of an item has started."""
153        def event_handler(data, events):
154            handler(data.to_py(), events)
155        self.listbox.events.on('dragStart', create_proxy(event_handler))
156
157    def on_focus_change(self, handler: Callable[[int, Union[str, int]], None]) -> None:
158        """Fires on moving focus to a new item."""
159        self.add_event_handler('focusChange', handler)
160
161    def on_item_mouse_over(self, handler: Callable[[Union[str, int], Any], None]) -> None:
162        """Fires on moving the mouse pointer over an item."""
163        self.add_event_handler('itemMouseOver', handler)
164
165    def on_item_right_click(self, handler: Callable[[Union[str, int], Any], None]) -> None:
166        """Fires on right-clicking an item."""
167        self.add_event_handler('itemRightClick', handler)
Listbox( config: ListboxConfig = None, widget_parent: str = None)
15    def __init__(self, config: ListboxConfig = None, widget_parent: str = None):
16        """
17        Initializes the ListBox widget.
18
19        :param config: (Optional) The ListBoxConfig object containing the list configuration.
20        :param widget_parent: (Optional) The ID of the HTML element where the list will be attached.
21        """
22        if config is None:
23            config = ListboxConfig()
24        config_dict = config.to_dict()
25        self.listbox = js.dhx.List.new(widget_parent, js.JSON.parse(json.dumps(config_dict)))

Initializes the ListBox widget.

Parameters
  • config: (Optional) The ListBoxConfig object containing the list configuration.
  • widget_parent: (Optional) The ID of the HTML element where the list will be attached.
listbox

ListBox API Functions

def destructor(self) -> None:
29    def destructor(self) -> None:
30        """Destroys the ListBox instance and releases resources."""
31        self.listbox.destructor()

Destroys the ListBox instance and releases resources.

def edit_item(self, item_id: Union[str, int]) -> None:
33    def edit_item(self, item_id: Union[str, int]) -> None:
34        """Enables editing of an item."""
35        self.listbox.editItem(item_id)

Enables editing of an item.

def get_focus(self) -> Union[str, int]:
37    def get_focus(self) -> Union[str, int]:
38        """Returns the ID of the item in focus."""
39        return self.listbox.getFocus()

Returns the ID of the item in focus.

def get_focus_item(self) -> Dict[str, Any]:
41    def get_focus_item(self) -> Dict[str, Any]:
42        """Returns the object of the item in focus."""
43        item = self.listbox.getFocusItem()
44        return item.to_py() if item else None

Returns the object of the item in focus.

def paint(self) -> None:
46    def paint(self) -> None:
47        """Repaints the list on the page."""
48        self.listbox.paint()

Repaints the list on the page.

def reset_focus(self) -> None:
50    def reset_focus(self) -> None:
51        """Resets focus and moves the scroll to the beginning of the list."""
52        self.listbox.resetFocus()

Resets focus and moves the scroll to the beginning of the list.

def set_focus(self, item_id: Union[str, int]) -> None:
54    def set_focus(self, item_id: Union[str, int]) -> None:
55        """Sets focus to an item by its ID and moves the scroll to it."""
56        self.listbox.setFocus(item_id)

Sets focus to an item by its ID and moves the scroll to it.

def add_event_handler(self, event_name: str, handler: Callable) -> None:
60    def add_event_handler(self, event_name: str, handler: Callable) -> None:
61        """Adds an event handler for the specified event."""
62        event_proxy = create_proxy(handler)
63        self.listbox.events.on(event_name, event_proxy)

Adds an event handler for the specified event.

def on_after_drag(self, handler: Callable[[Dict[str, Any], Any], NoneType]) -> None:
65    def on_after_drag(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
66        """Fires after dragging of an item is finished."""
67        def event_handler(data, events):
68            handler(data.to_py(), events)
69        self.listbox.events.on('afterDrag', create_proxy(event_handler))

Fires after dragging of an item is finished.

def on_after_drop(self, handler: Callable[[Dict[str, Any], Any], NoneType]) -> None:
71    def on_after_drop(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
72        """Fires before the user has finished dragging of an item but after the mouse button is released."""
73        def event_handler(data, events):
74            handler(data.to_py(), events)
75        self.listbox.events.on('afterDrop', create_proxy(event_handler))

Fires before the user has finished dragging of an item but after the mouse button is released.

def on_after_edit_end(self, handler: Callable[[str, Union[str, int]], NoneType]) -> None:
77    def on_after_edit_end(self, handler: Callable[[str, Union[str, int]], None]) -> None:
78        """Fires after editing of an item is ended."""
79        self.add_event_handler('afterEditEnd', handler)

Fires after editing of an item is ended.

def on_after_edit_start(self, handler: Callable[[Union[str, int]], NoneType]) -> None:
81    def on_after_edit_start(self, handler: Callable[[Union[str, int]], None]) -> None:
82        """Fires after editing of an item has started."""
83        self.add_event_handler('afterEditStart', handler)

Fires after editing of an item has started.

def on_before_drag(self, handler: Callable[[Dict[str, Any], Any], Optional[bool]]) -> None:
85    def on_before_drag(self, handler: Callable[[Dict[str, Any], Any], Union[bool, None]]) -> None:
86        """Fires before dragging of an item has started."""
87        def event_handler(data, events):
88            result = handler(data.to_py(), events)
89            if result is False:
90                return js.Boolean(False)
91        self.listbox.events.on('beforeDrag', create_proxy(event_handler))

Fires before dragging of an item has started.

def on_before_drop(self, handler: Callable[[Dict[str, Any], Any], Optional[bool]]) -> None:
93    def on_before_drop(self, handler: Callable[[Dict[str, Any], Any], Union[bool, None]]) -> None:
94        """Fires before the user has finished dragging of an item and released the mouse button."""
95        def event_handler(data, events):
96            result = handler(data.to_py(), events)
97            if result is False:
98                return js.Boolean(False)
99        self.listbox.events.on('beforeDrop', create_proxy(event_handler))

Fires before the user has finished dragging of an item and released the mouse button.

def on_before_edit_end(self, handler: Callable[[str, Union[str, int]], Optional[bool]]) -> None:
101    def on_before_edit_end(self, handler: Callable[[str, Union[str, int]], Union[bool, None]]) -> None:
102        """Fires before editing of an item is ended."""
103        def event_handler(value, id):
104            result = handler(value, id)
105            if result is False:
106                return js.Boolean(False)
107        self.listbox.events.on('beforeEditEnd', create_proxy(event_handler))

Fires before editing of an item is ended.

def on_before_edit_start(self, handler: Callable[[Union[str, int]], Optional[bool]]) -> None:
109    def on_before_edit_start(self, handler: Callable[[Union[str, int]], Union[bool, None]]) -> None:
110        """Fires before editing of an item has started."""
111        def event_handler(id):
112            result = handler(id)
113            if result is False:
114                return js.Boolean(False)
115        self.listbox.events.on('beforeEditStart', create_proxy(event_handler))

Fires before editing of an item has started.

def on_cancel_drop(self, handler: Callable[[Dict[str, Any], Any], NoneType]) -> None:
117    def on_cancel_drop(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
118        """Fires on moving a mouse pointer out of item's borders while dragging the item."""
119        def event_handler(data, events):
120            handler(data.to_py(), events)
121        self.listbox.events.on('cancelDrop', create_proxy(event_handler))

Fires on moving a mouse pointer out of item's borders while dragging the item.

def on_can_drop(self, handler: Callable[[Dict[str, Any], Any], NoneType]) -> None:
123    def on_can_drop(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
124        """Fires when a dragged item is over a target item."""
125        def event_handler(data, events):
126            handler(data.to_py(), events)
127        self.listbox.events.on('canDrop', create_proxy(event_handler))

Fires when a dragged item is over a target item.

def on_click(self, handler: Callable[[Union[str, int], Any], NoneType]) -> None:
129    def on_click(self, handler: Callable[[Union[str, int], Any], None]) -> None:
130        """Fires on clicking an item."""
131        self.add_event_handler('click', handler)

Fires on clicking an item.

def on_double_click(self, handler: Callable[[Union[str, int], Any], NoneType]) -> None:
133    def on_double_click(self, handler: Callable[[Union[str, int], Any], None]) -> None:
134        """Fires on double-clicking an item."""
135        self.add_event_handler('doubleClick', handler)

Fires on double-clicking an item.

def on_drag_in(self, handler: Callable[[Dict[str, Any], Any], Optional[bool]]) -> None:
137    def on_drag_in(self, handler: Callable[[Dict[str, Any], Any], Union[bool, None]]) -> None:
138        """Fires when an item is dragged to another potential target."""
139        def event_handler(data, events):
140            result = handler(data.to_py(), events)
141            if result is False:
142                return js.Boolean(False)
143        self.listbox.events.on('dragIn', create_proxy(event_handler))

Fires when an item is dragged to another potential target.

def on_drag_out(self, handler: Callable[[Dict[str, Any], Any], NoneType]) -> None:
145    def on_drag_out(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
146        """Fires when an item is dragged out of a potential target."""
147        def event_handler(data, events):
148            handler(data.to_py(), events)
149        self.listbox.events.on('dragOut', create_proxy(event_handler))

Fires when an item is dragged out of a potential target.

def on_drag_start(self, handler: Callable[[Dict[str, Any], Any], NoneType]) -> None:
151    def on_drag_start(self, handler: Callable[[Dict[str, Any], Any], None]) -> None:
152        """Fires when dragging of an item has started."""
153        def event_handler(data, events):
154            handler(data.to_py(), events)
155        self.listbox.events.on('dragStart', create_proxy(event_handler))

Fires when dragging of an item has started.

def on_focus_change(self, handler: Callable[[int, Union[str, int]], NoneType]) -> None:
157    def on_focus_change(self, handler: Callable[[int, Union[str, int]], None]) -> None:
158        """Fires on moving focus to a new item."""
159        self.add_event_handler('focusChange', handler)

Fires on moving focus to a new item.

def on_item_mouse_over(self, handler: Callable[[Union[str, int], Any], NoneType]) -> None:
161    def on_item_mouse_over(self, handler: Callable[[Union[str, int], Any], None]) -> None:
162        """Fires on moving the mouse pointer over an item."""
163        self.add_event_handler('itemMouseOver', handler)

Fires on moving the mouse pointer over an item.

def on_item_right_click(self, handler: Callable[[Union[str, int], Any], NoneType]) -> None:
165    def on_item_right_click(self, handler: Callable[[Union[str, int], Any], None]) -> None:
166        """Fires on right-clicking an item."""
167        self.add_event_handler('itemRightClick', handler)

Fires on right-clicking an item.

class ListboxConfig:
 6class ListboxConfig:
 7    """
 8    Configuration class for the ListBox widget.
 9    """
10    def __init__(self,
11                 data: list = None,
12                 css: str = None,
13                 dragCopy: bool = False,
14                 dragMode: str = None,
15                 editable: bool = False,
16                 eventHandlers: Dict[str, Dict[str, Callable]] = None,
17                 height: Union[int, str] = "auto",
18                 htmlEnable: bool = True,
19                 itemHeight: Union[int, str] = 37,
20                 keyNavigation: Union[bool, Callable[[], bool]] = True,
21                 multiselection: Union[bool, str] = False,
22                 selection: bool = True,
23                 template: Callable[[Dict[str, Any]], str] = None,
24                 virtual: bool = False):
25        """
26        Initializes the ListBoxConfig.
27
28        :param data: (Optional) List of data items.
29        :param css: (Optional) Adds a CSS class(es) to the component.
30        :param dragCopy: (Optional) Defines that an item is copied to a target during drag-n-drop.
31        :param dragMode: (Optional) Enables drag-n-drop in ListBox.
32        :param editable: (Optional) Enables editing in ListBox.
33        :param eventHandlers: (Optional) Adds event handlers to HTML elements of a custom template.
34        :param height: (Optional) Sets the height of ListBox.
35        :param htmlEnable: (Optional) Enables/disables rendering of HTML content.
36        :param itemHeight: (Optional) Sets the height of an item.
37        :param keyNavigation: (Optional) Enables/disables navigation by arrow keys.
38        :param multiselection: (Optional) Enables multiselection mode.
39        :param selection: (Optional) Enables selection of ListBox items.
40        :param template: (Optional) Specifies a template for ListBox items.
41        :param virtual: (Optional) Enables dynamic rendering of ListBox items.
42        """
43        self.data = data
44        self.css = css
45        self.dragCopy = dragCopy
46        self.dragMode = dragMode
47        self.editable = editable
48        self.eventHandlers = eventHandlers
49        self.height = height
50        self.htmlEnable = htmlEnable
51        self.itemHeight = itemHeight
52        self.keyNavigation = keyNavigation
53        self.multiselection = multiselection
54        self.selection = selection
55        self.template = template
56        self.virtual = virtual
57
58    def to_dict(self) -> Dict[str, Any]:
59        """
60        Converts the ListBoxConfig into a dictionary format.
61        """
62        config_dict = {
63            'data': self.data,
64            'css': self.css,
65            'dragCopy': self.dragCopy,
66            'dragMode': self.dragMode,
67            'editable': self.editable,
68            'eventHandlers': self.eventHandlers,
69            'height': self.height,
70            'htmlEnable': self.htmlEnable,
71            'itemHeight': self.itemHeight,
72            'keyNavigation': self.keyNavigation,
73            'multiselection': self.multiselection,
74            'selection': self.selection,
75            'template': self.template,
76            'virtual': self.virtual,
77        }
78        # Remove None values
79        config_dict = {k: v for k, v in config_dict.items() if v is not None}
80
81        # Handle functions (e.g., template, keyNavigation)
82        if 'template' in config_dict and callable(config_dict['template']):
83            # Assuming template is a JavaScript function or needs to be converted
84            config_dict['template'] = create_proxy(self.template)
85
86        if 'keyNavigation' in config_dict and callable(config_dict['keyNavigation']):
87            config_dict['keyNavigation'] = create_proxy(self.keyNavigation)
88
89        return config_dict

Configuration class for the ListBox widget.

ListboxConfig( data: list = None, css: str = None, dragCopy: bool = False, dragMode: str = None, editable: bool = False, eventHandlers: Dict[str, Dict[str, Callable]] = None, height: Union[int, str] = 'auto', htmlEnable: bool = True, itemHeight: Union[int, str] = 37, keyNavigation: Union[bool, Callable[[], bool]] = True, multiselection: Union[bool, str] = False, selection: bool = True, template: Callable[[Dict[str, Any]], str] = None, virtual: bool = False)
10    def __init__(self,
11                 data: list = None,
12                 css: str = None,
13                 dragCopy: bool = False,
14                 dragMode: str = None,
15                 editable: bool = False,
16                 eventHandlers: Dict[str, Dict[str, Callable]] = None,
17                 height: Union[int, str] = "auto",
18                 htmlEnable: bool = True,
19                 itemHeight: Union[int, str] = 37,
20                 keyNavigation: Union[bool, Callable[[], bool]] = True,
21                 multiselection: Union[bool, str] = False,
22                 selection: bool = True,
23                 template: Callable[[Dict[str, Any]], str] = None,
24                 virtual: bool = False):
25        """
26        Initializes the ListBoxConfig.
27
28        :param data: (Optional) List of data items.
29        :param css: (Optional) Adds a CSS class(es) to the component.
30        :param dragCopy: (Optional) Defines that an item is copied to a target during drag-n-drop.
31        :param dragMode: (Optional) Enables drag-n-drop in ListBox.
32        :param editable: (Optional) Enables editing in ListBox.
33        :param eventHandlers: (Optional) Adds event handlers to HTML elements of a custom template.
34        :param height: (Optional) Sets the height of ListBox.
35        :param htmlEnable: (Optional) Enables/disables rendering of HTML content.
36        :param itemHeight: (Optional) Sets the height of an item.
37        :param keyNavigation: (Optional) Enables/disables navigation by arrow keys.
38        :param multiselection: (Optional) Enables multiselection mode.
39        :param selection: (Optional) Enables selection of ListBox items.
40        :param template: (Optional) Specifies a template for ListBox items.
41        :param virtual: (Optional) Enables dynamic rendering of ListBox items.
42        """
43        self.data = data
44        self.css = css
45        self.dragCopy = dragCopy
46        self.dragMode = dragMode
47        self.editable = editable
48        self.eventHandlers = eventHandlers
49        self.height = height
50        self.htmlEnable = htmlEnable
51        self.itemHeight = itemHeight
52        self.keyNavigation = keyNavigation
53        self.multiselection = multiselection
54        self.selection = selection
55        self.template = template
56        self.virtual = virtual

Initializes the ListBoxConfig.

Parameters
  • data: (Optional) List of data items.
  • css: (Optional) Adds a CSS class(es) to the component.
  • dragCopy: (Optional) Defines that an item is copied to a target during drag-n-drop.
  • dragMode: (Optional) Enables drag-n-drop in ListBox.
  • editable: (Optional) Enables editing in ListBox.
  • eventHandlers: (Optional) Adds event handlers to HTML elements of a custom template.
  • height: (Optional) Sets the height of ListBox.
  • htmlEnable: (Optional) Enables/disables rendering of HTML content.
  • itemHeight: (Optional) Sets the height of an item.
  • keyNavigation: (Optional) Enables/disables navigation by arrow keys.
  • multiselection: (Optional) Enables multiselection mode.
  • selection: (Optional) Enables selection of ListBox items.
  • template: (Optional) Specifies a template for ListBox items.
  • virtual: (Optional) Enables dynamic rendering of ListBox items.
data
css
dragCopy
dragMode
editable
eventHandlers
height
htmlEnable
itemHeight
keyNavigation
multiselection
selection
template
virtual
def to_dict(self) -> Dict[str, Any]:
58    def to_dict(self) -> Dict[str, Any]:
59        """
60        Converts the ListBoxConfig into a dictionary format.
61        """
62        config_dict = {
63            'data': self.data,
64            'css': self.css,
65            'dragCopy': self.dragCopy,
66            'dragMode': self.dragMode,
67            'editable': self.editable,
68            'eventHandlers': self.eventHandlers,
69            'height': self.height,
70            'htmlEnable': self.htmlEnable,
71            'itemHeight': self.itemHeight,
72            'keyNavigation': self.keyNavigation,
73            'multiselection': self.multiselection,
74            'selection': self.selection,
75            'template': self.template,
76            'virtual': self.virtual,
77        }
78        # Remove None values
79        config_dict = {k: v for k, v in config_dict.items() if v is not None}
80
81        # Handle functions (e.g., template, keyNavigation)
82        if 'template' in config_dict and callable(config_dict['template']):
83            # Assuming template is a JavaScript function or needs to be converted
84            config_dict['template'] = create_proxy(self.template)
85
86        if 'keyNavigation' in config_dict and callable(config_dict['keyNavigation']):
87            config_dict['keyNavigation'] = create_proxy(self.keyNavigation)
88
89        return config_dict

Converts the ListBoxConfig into a dictionary format.