dhxpyt.tabbar

1from .tabbar import Tabbar
2from .tabbar_config import TabbarConfig, TabConfig
3
4__all__ = ["Tabbar", "TabbarConfig", "TabConfig"]
class Tabbar:
 33class Tabbar:
 34    def __init__(self, config: TabbarConfig = None, widget_parent: Any = None):
 35        """Initializes the Tabbar instance."""
 36        if config is None:
 37            config = TabbarConfig()
 38        config_dict = config.to_dict()
 39        self.tabbar = js.dhx.Tabbar.new(widget_parent, js.JSON.parse(json.dumps(config_dict)))
 40
 41    """ Placeholder Widgets Adders """
 42
 43    def add_grid(self, id: str = "mainwindow", grid_config: GridConfig = None) -> Grid:
 44        """Adds a Grid widget into a Layout cell."""
 45        grid_widget = Grid(config=grid_config)
 46        self.attach(id, grid_widget.grid)
 47        if grid_config.data:
 48            grid_widget.grid.data.parse(js.JSON.parse(json.dumps(grid_config.data)))
 49        return grid_widget
 50    
 51    def add_cardflow(self, id: str, cardflow_config: CardFlowConfig = None) -> Any:
 52        """Adds a CardFlow widget into a Layout cell."""
 53        cardflow_widget = CardFlow(config=cardflow_config, container=self.tabbar.getCell(id))
 54        return cardflow_widget
 55    
 56    #def add_layout(self, id: str = "mainwindow", layout_config: LayoutConfig = None) -> TLayout:
 57    #    """ Adds a Layout into a Layout cell """
 58    #    layout_widget = Layout(config=layout_config)
 59    #    self.attach(id, layout_widget.layout)
 60    #    return layout_widget
 61
 62        # Define a function to wait for the element to be ready
 63    def wait_for_element(self, selector, callback):
 64        def check_element():
 65            if js.document.querySelector(selector):
 66                callback()
 67            else:
 68                js.window.setTimeout(create_proxy(check_element), 100)  # Check again after 100ms
 69
 70        check_element()
 71
 72    def add_kanban(self, id: str = "mainwindow", kanban_config: KanbanConfig = None, kanban_callback: callable = None) -> None:
 73        self.kanban_callback = kanban_callback
 74        self.kanban_config = kanban_config
 75        self.kanban_div_id = "kanban_root_" + str(uuid4()).replace("-", "") #"kanban_root"
 76        self.attach_html(id, f'<div id="{self.kanban_div_id}" style="width:100%;height:100%;"></div>')
 77        self.wait_for_element(f"#{self.kanban_div_id}", self.create_kanban)
 78
 79    def create_kanban(self):
 80        return_kanban = Kanban(self.kanban_config, f"#{self.kanban_div_id}")
 81        current_theme = js.document.documentElement.getAttribute('data-dhx-theme')
 82        if current_theme == "dark":
 83            theme = "willow-dark"
 84        else:
 85            theme = "willow"
 86
 87        return_kanban.kanban.setTheme(js.JSON.parse(json.dumps({"name": theme, "fonts": True})))
 88        self.kanban_callback(return_kanban)
 89    
 90    def add_menu(self, id: str = "mainwindow_header", menu_config: MenuConfig = None) -> Menu:
 91        """ Adds a Layout into a Layout cell """
 92        menu_widget = Menu(config=menu_config)
 93        self.attach(id, menu_widget.menu)
 94        return menu_widget
 95
 96    def add_toolbar(self, id: str = "mainwindow", toolbar_config: ToolbarConfig = None) -> Toolbar:
 97        """Adds a Toolbar widget into a Layout cell."""
 98        toolbar_widget = Toolbar(config=toolbar_config)
 99        self.attach(id, toolbar_widget.toolbar)
100        return toolbar_widget
101
102    def add_sidebar(self, id: str, sidebar_config: SidebarConfig = None) -> Sidebar:
103        """Adds a Sidebar widget into a Layout cell."""
104        sidebar_widget = Sidebar(config=sidebar_config)
105        self.attach(id, sidebar_widget.sidebar)
106        return sidebar_widget
107
108    def add_form(self, id: str, form_config: FormConfig = None) -> Form:
109        """Adds a Form widget into a Layout cell."""
110        form_widget = Form(config=form_config)
111        self.attach(id, form_widget.form)
112        return form_widget
113    
114    def add_listbox(self, id: str, listbox_config: ListboxConfig = None) -> Any:
115        """Adds a Listbox widget into a Layout cell."""
116        listbox_widget = Listbox(config=listbox_config)
117        self.attach(id, listbox_widget.listbox)
118        return listbox_widget
119    
120    def add_calendar(self, id: str, calendar_config: CalendarConfig = None) -> Any:
121        """Adds a Calendar widget into a Layout cell."""
122        calendar_widget = Calendar(config=calendar_config)
123        self.attach(id, calendar_widget.calendar)
124        return calendar_widget
125    
126    def add_chart(self, id: str, chart_config: ChartConfig = None) -> Any:
127        """Adds a Chart widget into a Layout cell."""
128        chart_widget = Chart(config=chart_config)
129        self.attach(id, chart_widget.chart)
130        return chart_widget
131    
132    def add_pagination(self, id: str, pagination_config: PaginationConfig = None) -> Any:
133        """Adds a Pagination widget into a Layout cell."""
134        pagination_widget = Pagination(config=pagination_config)
135        self.attach(id, pagination_widget.pagination)
136        return pagination_widget
137    
138    def add_ribbon(self, id: str, ribbon_config: RibbonConfig = None) -> Any:
139        """Adds a Ribbon widget into a Layout cell."""
140        ribbon_widget = Ribbon(config=ribbon_config)
141        self.attach(id, ribbon_widget.ribbon)
142        return ribbon_widget
143    
144    def add_tabbar(self, id: str, tabbar_config: TabbarConfig = None) -> Any:
145        """Adds a Tabbar widget into a Layout cell."""
146        tabbar_widget = Tabbar(config=tabbar_config)
147        self.attach(id, tabbar_widget.tabbar)
148        return tabbar_widget
149    
150    def add_timepicker(self, id: str, timepicker_config: TimepickerConfig = None) -> Any:
151        """Adds a Timepicker widget into a Layout cell."""
152        timepicker_widget = Timepicker(config=timepicker_config)
153        self.attach(id, timepicker_widget.timepicker)
154        return timepicker_widget
155    
156    def add_tree(self, id: str, tree_config: TreeConfig = None) -> Any:
157        """Adds a Tree widget into a Layout cell."""
158        tree_widget = Tree(config=tree_config)
159        self.attach(id, tree_widget.tree)
160        return tree_widget
161
162    """ Tabbar API Methods """
163
164    def add_tab(self, config: Dict[str, Any], index: int) -> None:
165        """Adds a new tab into a tabbar."""
166        self.tabbar.addTab(js.JSON.parse(json.dumps(config)), index)
167
168    def destructor(self) -> None:
169        """Removes the Tabbar instance and releases occupied resources."""
170        self.tabbar.destructor()
171
172    def disable_tab(self, id: str) -> bool:
173        """Disables a tab on a page."""
174        return self.tabbar.disableTab(id)
175
176    def enable_tab(self, id: str) -> None:
177        """Enables a disabled tab."""
178        self.tabbar.enableTab(id)
179
180    def get_active(self) -> str:
181        """Gets the id of the active tab."""
182        return self.tabbar.getActive()
183
184    def get_cell(self, id: str) -> Any:
185        """Returns the config object of a cell."""
186        return self.tabbar.getCell(id)
187
188    def get_id(self, index: int) -> str:
189        """Returns the id of a tab by its index."""
190        return self.tabbar.getId(index)
191
192    def get_widget(self) -> Any:
193        """Returns the widget attached to Tabbar."""
194        return self.tabbar.getWidget()
195
196    def is_disabled(self, id: str) -> bool:
197        """Checks whether a tab is disabled."""
198        return self.tabbar.isDisabled(id)
199
200    def paint(self) -> None:
201        """Repaints the Tabbar on a page."""
202        self.tabbar.paint()
203
204    def remove_tab(self, id: str) -> None:
205        """Removes a tab from a tabbar."""
206        self.tabbar.removeTab(id)
207
208    def set_active(self, id: str) -> None:
209        """Sets an active tab."""
210        self.tabbar.setActive(id)
211
212    """ Tabbar Events """
213
214    def add_event_handler(self, event_name: str, handler: Callable) -> None:
215        """Helper to add event handlers dynamically."""
216        event_proxy = create_proxy(handler)
217        self.tabbar.events.on(event_name, event_proxy)
218
219    def on_after_close(self, handler: Callable[[str], None]) -> None:
220        """Fires after closing a tab in Tabbar."""
221        self.add_event_handler('afterClose', handler)
222
223    def on_before_change(self, handler: Callable[[str, str], Union[bool, None]]) -> None:
224        """Fires before changing the active tab."""
225        def event_handler(id, prev):
226            result = handler(id, prev)
227            if result is False:
228                return js.Boolean(False)
229        event_proxy = create_proxy(event_handler)
230        self.tabbar.events.on('beforeChange', event_proxy)
231
232    def on_before_close(self, handler: Callable[[str], Union[bool, None]]) -> None:
233        """Fires before closing a tab in Tabbar."""
234        def event_handler(id):
235            result = handler(id)
236            if result is False:
237                return js.Boolean(False)
238        event_proxy = create_proxy(event_handler)
239        self.tabbar.events.on('beforeClose', event_proxy)
240
241    def on_change(self, handler: Callable[[str, str], None]) -> None:
242        """Fires on changing the active tab."""
243        self.add_event_handler('change', handler)
244        return True
245
246    """ Tabbar Properties """
247
248    @property
249    def active_tab(self) -> str:
250        """Gets or sets the currently active tab."""
251        return self.tabbar.config.activeTab
252
253    @active_tab.setter
254    def active_tab(self, value: str) -> None:
255        self.tabbar.config.activeTab = value
256
257    @property
258    def closable(self) -> Union[bool, List[str]]:
259        """Gets or sets the closable property for tabs."""
260        return self.tabbar.config.closable
261
262    @closable.setter
263    def closable(self, value: Union[bool, List[str]]) -> None:
264        self.tabbar.config.closable = value
265
266    @property
267    def css(self) -> str:
268        """Gets or sets the CSS class(es) applied to Tabbar."""
269        return self.tabbar.config.css
270
271    @css.setter
272    def css(self, value: str) -> None:
273        self.tabbar.config.css = value
274
275    @property
276    def disabled(self) -> Union[str, List[str]]:
277        """Gets or sets disabled tabs."""
278        return self.tabbar.config.disabled
279
280    @disabled.setter
281    def disabled(self, value: Union[str, List[str]]) -> None:
282        self.tabbar.config.disabled = value
283
284    @property
285    def mode(self) -> str:
286        """Gets or sets the mode of displaying a tabbar."""
287        return self.tabbar.config.mode
288
289    @mode.setter
290    def mode(self, value: str) -> None:
291        self.tabbar.config.mode = value
292
293    @property
294    def no_content(self) -> bool:
295        """Gets or sets whether tabs contain any content."""
296        return self.tabbar.config.noContent
297
298    @no_content.setter
299    def no_content(self, value: bool) -> None:
300        self.tabbar.config.noContent = value
301
302    @property
303    def tab_align(self) -> str:
304        """Gets or sets alignment for tabs."""
305        return self.tabbar.config.tabAlign
306
307    @tab_align.setter
308    def tab_align(self, value: str) -> None:
309        self.tabbar.config.tabAlign = value
310
311    @property
312    def tab_auto_height(self) -> bool:
313        """Gets or sets whether the height of tabs is automatically adjusted."""
314        return self.tabbar.config.tabAutoHeight
315
316    @tab_auto_height.setter
317    def tab_auto_height(self, value: bool) -> None:
318        self.tabbar.config.tabAutoHeight = value
319
320    @property
321    def tab_auto_width(self) -> bool:
322        """Gets or sets whether the width of tabs is automatically adjusted."""
323        return self.tabbar.config.tabAutoWidth
324
325    @tab_auto_width.setter
326    def tab_auto_width(self, value: bool) -> None:
327        self.tabbar.config.tabAutoWidth = value
328
329    @property
330    def tab_height(self) -> Union[int, str]:
331        """Gets or sets the height of a tab."""
332        return self.tabbar.config.tabHeight
333
334    @tab_height.setter
335    def tab_height(self, value: Union[int, str]) -> None:
336        self.tabbar.config.tabHeight = value
337
338    @property
339    def tab_width(self) -> Union[int, str]:
340        """Gets or sets the width of a tab."""
341        return self.tabbar.config.tabWidth
342
343    @tab_width.setter
344    def tab_width(self, value: Union[int, str]) -> None:
345        self.tabbar.config.tabWidth = value
346
347    @property
348    def views(self) -> List[Dict[str, Any]]:
349        """Gets or sets the configuration of tabs."""
350        return self.tabbar.config.views
351
352    @views.setter
353    def views(self, value: List[Dict[str, Any]]) -> None:
354        self.tabbar.config.views = value
355
356    """ Tabbar Cell API Functions """
357
358    def attach(self, id: str, component: Union[str, Any], config: Dict[str, Any] = None) -> Any:
359        """Attaches a DHTMLX component into a Tabbar cell."""
360        return self.tabbar.getCell(id).attach(component, js.JSON.parse(json.dumps(config or {})))
361
362    def attach_html(self, id: str, html: str) -> None:
363        """Adds HTML content into a Tabbar cell."""
364        self.tabbar.getCell(id).attachHTML(html)
365
366    def get_cell_parent(self, id: str) -> Any:
367        """Returns the parent of a cell."""
368        return self.tabbar.getCell(id).getParent()
369
370    def get_cell_widget(self, id: str) -> Any:
371        """Returns the widget attached to a Tabbar cell."""
372        return self.tabbar.getCell(id).getWidget()
Tabbar( config: TabbarConfig = None, widget_parent: Any = None)
34    def __init__(self, config: TabbarConfig = None, widget_parent: Any = None):
35        """Initializes the Tabbar instance."""
36        if config is None:
37            config = TabbarConfig()
38        config_dict = config.to_dict()
39        self.tabbar = js.dhx.Tabbar.new(widget_parent, js.JSON.parse(json.dumps(config_dict)))

Initializes the Tabbar instance.

tabbar

Placeholder Widgets Adders

def add_grid( self, id: str = 'mainwindow', grid_config: dhxpyt.grid.GridConfig = None) -> dhxpyt.grid.Grid:
43    def add_grid(self, id: str = "mainwindow", grid_config: GridConfig = None) -> Grid:
44        """Adds a Grid widget into a Layout cell."""
45        grid_widget = Grid(config=grid_config)
46        self.attach(id, grid_widget.grid)
47        if grid_config.data:
48            grid_widget.grid.data.parse(js.JSON.parse(json.dumps(grid_config.data)))
49        return grid_widget

Adds a Grid widget into a Layout cell.

def add_cardflow( self, id: str, cardflow_config: dhxpyt.cardflow.CardFlowConfig = None) -> Any:
51    def add_cardflow(self, id: str, cardflow_config: CardFlowConfig = None) -> Any:
52        """Adds a CardFlow widget into a Layout cell."""
53        cardflow_widget = CardFlow(config=cardflow_config, container=self.tabbar.getCell(id))
54        return cardflow_widget
55    
56    #def add_layout(self, id: str = "mainwindow", layout_config: LayoutConfig = None) -> TLayout:
57    #    """ Adds a Layout into a Layout cell """
58    #    layout_widget = Layout(config=layout_config)
59    #    self.attach(id, layout_widget.layout)
60    #    return layout_widget
61
62        # Define a function to wait for the element to be ready

Adds a CardFlow widget into a Layout cell.

def wait_for_element(self, selector, callback):
63    def wait_for_element(self, selector, callback):
64        def check_element():
65            if js.document.querySelector(selector):
66                callback()
67            else:
68                js.window.setTimeout(create_proxy(check_element), 100)  # Check again after 100ms
69
70        check_element()
def add_kanban( self, id: str = 'mainwindow', kanban_config: dhxpyt.kanban.KanbanConfig = None, kanban_callback: <built-in function callable> = None) -> None:
72    def add_kanban(self, id: str = "mainwindow", kanban_config: KanbanConfig = None, kanban_callback: callable = None) -> None:
73        self.kanban_callback = kanban_callback
74        self.kanban_config = kanban_config
75        self.kanban_div_id = "kanban_root_" + str(uuid4()).replace("-", "") #"kanban_root"
76        self.attach_html(id, f'<div id="{self.kanban_div_id}" style="width:100%;height:100%;"></div>')
77        self.wait_for_element(f"#{self.kanban_div_id}", self.create_kanban)
def create_kanban(self):
79    def create_kanban(self):
80        return_kanban = Kanban(self.kanban_config, f"#{self.kanban_div_id}")
81        current_theme = js.document.documentElement.getAttribute('data-dhx-theme')
82        if current_theme == "dark":
83            theme = "willow-dark"
84        else:
85            theme = "willow"
86
87        return_kanban.kanban.setTheme(js.JSON.parse(json.dumps({"name": theme, "fonts": True})))
88        self.kanban_callback(return_kanban)
def add_menu( self, id: str = 'mainwindow_header', menu_config: dhxpyt.menu.MenuConfig = None) -> dhxpyt.menu.Menu:
90    def add_menu(self, id: str = "mainwindow_header", menu_config: MenuConfig = None) -> Menu:
91        """ Adds a Layout into a Layout cell """
92        menu_widget = Menu(config=menu_config)
93        self.attach(id, menu_widget.menu)
94        return menu_widget

Adds a Layout into a Layout cell

def add_toolbar( self, id: str = 'mainwindow', toolbar_config: dhxpyt.toolbar.ToolbarConfig = None) -> dhxpyt.toolbar.Toolbar:
 96    def add_toolbar(self, id: str = "mainwindow", toolbar_config: ToolbarConfig = None) -> Toolbar:
 97        """Adds a Toolbar widget into a Layout cell."""
 98        toolbar_widget = Toolbar(config=toolbar_config)
 99        self.attach(id, toolbar_widget.toolbar)
100        return toolbar_widget

Adds a Toolbar widget into a Layout cell.

def add_sidebar( self, id: str, sidebar_config: dhxpyt.sidebar.SidebarConfig = None) -> dhxpyt.sidebar.Sidebar:
102    def add_sidebar(self, id: str, sidebar_config: SidebarConfig = None) -> Sidebar:
103        """Adds a Sidebar widget into a Layout cell."""
104        sidebar_widget = Sidebar(config=sidebar_config)
105        self.attach(id, sidebar_widget.sidebar)
106        return sidebar_widget

Adds a Sidebar widget into a Layout cell.

def add_form( self, id: str, form_config: dhxpyt.form.FormConfig = None) -> dhxpyt.form.Form:
108    def add_form(self, id: str, form_config: FormConfig = None) -> Form:
109        """Adds a Form widget into a Layout cell."""
110        form_widget = Form(config=form_config)
111        self.attach(id, form_widget.form)
112        return form_widget

Adds a Form widget into a Layout cell.

def add_listbox( self, id: str, listbox_config: dhxpyt.listbox.ListboxConfig = None) -> Any:
114    def add_listbox(self, id: str, listbox_config: ListboxConfig = None) -> Any:
115        """Adds a Listbox widget into a Layout cell."""
116        listbox_widget = Listbox(config=listbox_config)
117        self.attach(id, listbox_widget.listbox)
118        return listbox_widget

Adds a Listbox widget into a Layout cell.

def add_calendar( self, id: str, calendar_config: dhxpyt.calendar.CalendarConfig = None) -> Any:
120    def add_calendar(self, id: str, calendar_config: CalendarConfig = None) -> Any:
121        """Adds a Calendar widget into a Layout cell."""
122        calendar_widget = Calendar(config=calendar_config)
123        self.attach(id, calendar_widget.calendar)
124        return calendar_widget

Adds a Calendar widget into a Layout cell.

def add_chart( self, id: str, chart_config: dhxpyt.chart.ChartConfig = None) -> Any:
126    def add_chart(self, id: str, chart_config: ChartConfig = None) -> Any:
127        """Adds a Chart widget into a Layout cell."""
128        chart_widget = Chart(config=chart_config)
129        self.attach(id, chart_widget.chart)
130        return chart_widget

Adds a Chart widget into a Layout cell.

def add_pagination( self, id: str, pagination_config: dhxpyt.pagination.PaginationConfig = None) -> Any:
132    def add_pagination(self, id: str, pagination_config: PaginationConfig = None) -> Any:
133        """Adds a Pagination widget into a Layout cell."""
134        pagination_widget = Pagination(config=pagination_config)
135        self.attach(id, pagination_widget.pagination)
136        return pagination_widget

Adds a Pagination widget into a Layout cell.

def add_ribbon( self, id: str, ribbon_config: dhxpyt.ribbon.RibbonConfig = None) -> Any:
138    def add_ribbon(self, id: str, ribbon_config: RibbonConfig = None) -> Any:
139        """Adds a Ribbon widget into a Layout cell."""
140        ribbon_widget = Ribbon(config=ribbon_config)
141        self.attach(id, ribbon_widget.ribbon)
142        return ribbon_widget

Adds a Ribbon widget into a Layout cell.

def add_tabbar( self, id: str, tabbar_config: TabbarConfig = None) -> Any:
144    def add_tabbar(self, id: str, tabbar_config: TabbarConfig = None) -> Any:
145        """Adds a Tabbar widget into a Layout cell."""
146        tabbar_widget = Tabbar(config=tabbar_config)
147        self.attach(id, tabbar_widget.tabbar)
148        return tabbar_widget

Adds a Tabbar widget into a Layout cell.

def add_timepicker( self, id: str, timepicker_config: dhxpyt.timepicker.TimepickerConfig = None) -> Any:
150    def add_timepicker(self, id: str, timepicker_config: TimepickerConfig = None) -> Any:
151        """Adds a Timepicker widget into a Layout cell."""
152        timepicker_widget = Timepicker(config=timepicker_config)
153        self.attach(id, timepicker_widget.timepicker)
154        return timepicker_widget

Adds a Timepicker widget into a Layout cell.

def add_tree( self, id: str, tree_config: dhxpyt.tree.TreeConfig = None) -> Any:
156    def add_tree(self, id: str, tree_config: TreeConfig = None) -> Any:
157        """Adds a Tree widget into a Layout cell."""
158        tree_widget = Tree(config=tree_config)
159        self.attach(id, tree_widget.tree)
160        return tree_widget

Adds a Tree widget into a Layout cell.

def add_tab(self, config: Dict[str, Any], index: int) -> None:
164    def add_tab(self, config: Dict[str, Any], index: int) -> None:
165        """Adds a new tab into a tabbar."""
166        self.tabbar.addTab(js.JSON.parse(json.dumps(config)), index)

Adds a new tab into a tabbar.

def destructor(self) -> None:
168    def destructor(self) -> None:
169        """Removes the Tabbar instance and releases occupied resources."""
170        self.tabbar.destructor()

Removes the Tabbar instance and releases occupied resources.

def disable_tab(self, id: str) -> bool:
172    def disable_tab(self, id: str) -> bool:
173        """Disables a tab on a page."""
174        return self.tabbar.disableTab(id)

Disables a tab on a page.

def enable_tab(self, id: str) -> None:
176    def enable_tab(self, id: str) -> None:
177        """Enables a disabled tab."""
178        self.tabbar.enableTab(id)

Enables a disabled tab.

def get_active(self) -> str:
180    def get_active(self) -> str:
181        """Gets the id of the active tab."""
182        return self.tabbar.getActive()

Gets the id of the active tab.

def get_cell(self, id: str) -> Any:
184    def get_cell(self, id: str) -> Any:
185        """Returns the config object of a cell."""
186        return self.tabbar.getCell(id)

Returns the config object of a cell.

def get_id(self, index: int) -> str:
188    def get_id(self, index: int) -> str:
189        """Returns the id of a tab by its index."""
190        return self.tabbar.getId(index)

Returns the id of a tab by its index.

def get_widget(self) -> Any:
192    def get_widget(self) -> Any:
193        """Returns the widget attached to Tabbar."""
194        return self.tabbar.getWidget()

Returns the widget attached to Tabbar.

def is_disabled(self, id: str) -> bool:
196    def is_disabled(self, id: str) -> bool:
197        """Checks whether a tab is disabled."""
198        return self.tabbar.isDisabled(id)

Checks whether a tab is disabled.

def paint(self) -> None:
200    def paint(self) -> None:
201        """Repaints the Tabbar on a page."""
202        self.tabbar.paint()

Repaints the Tabbar on a page.

def remove_tab(self, id: str) -> None:
204    def remove_tab(self, id: str) -> None:
205        """Removes a tab from a tabbar."""
206        self.tabbar.removeTab(id)

Removes a tab from a tabbar.

def set_active(self, id: str) -> None:
208    def set_active(self, id: str) -> None:
209        """Sets an active tab."""
210        self.tabbar.setActive(id)

Sets an active tab.

def add_event_handler(self, event_name: str, handler: Callable) -> None:
214    def add_event_handler(self, event_name: str, handler: Callable) -> None:
215        """Helper to add event handlers dynamically."""
216        event_proxy = create_proxy(handler)
217        self.tabbar.events.on(event_name, event_proxy)

Helper to add event handlers dynamically.

def on_after_close(self, handler: Callable[[str], NoneType]) -> None:
219    def on_after_close(self, handler: Callable[[str], None]) -> None:
220        """Fires after closing a tab in Tabbar."""
221        self.add_event_handler('afterClose', handler)

Fires after closing a tab in Tabbar.

def on_before_change(self, handler: Callable[[str, str], Optional[bool]]) -> None:
223    def on_before_change(self, handler: Callable[[str, str], Union[bool, None]]) -> None:
224        """Fires before changing the active tab."""
225        def event_handler(id, prev):
226            result = handler(id, prev)
227            if result is False:
228                return js.Boolean(False)
229        event_proxy = create_proxy(event_handler)
230        self.tabbar.events.on('beforeChange', event_proxy)

Fires before changing the active tab.

def on_before_close(self, handler: Callable[[str], Optional[bool]]) -> None:
232    def on_before_close(self, handler: Callable[[str], Union[bool, None]]) -> None:
233        """Fires before closing a tab in Tabbar."""
234        def event_handler(id):
235            result = handler(id)
236            if result is False:
237                return js.Boolean(False)
238        event_proxy = create_proxy(event_handler)
239        self.tabbar.events.on('beforeClose', event_proxy)

Fires before closing a tab in Tabbar.

def on_change(self, handler: Callable[[str, str], NoneType]) -> None:
241    def on_change(self, handler: Callable[[str, str], None]) -> None:
242        """Fires on changing the active tab."""
243        self.add_event_handler('change', handler)
244        return True

Fires on changing the active tab.

active_tab: str
248    @property
249    def active_tab(self) -> str:
250        """Gets or sets the currently active tab."""
251        return self.tabbar.config.activeTab

Gets or sets the currently active tab.

closable: Union[bool, List[str]]
257    @property
258    def closable(self) -> Union[bool, List[str]]:
259        """Gets or sets the closable property for tabs."""
260        return self.tabbar.config.closable

Gets or sets the closable property for tabs.

css: str
266    @property
267    def css(self) -> str:
268        """Gets or sets the CSS class(es) applied to Tabbar."""
269        return self.tabbar.config.css

Gets or sets the CSS class(es) applied to Tabbar.

disabled: Union[str, List[str]]
275    @property
276    def disabled(self) -> Union[str, List[str]]:
277        """Gets or sets disabled tabs."""
278        return self.tabbar.config.disabled

Gets or sets disabled tabs.

mode: str
284    @property
285    def mode(self) -> str:
286        """Gets or sets the mode of displaying a tabbar."""
287        return self.tabbar.config.mode

Gets or sets the mode of displaying a tabbar.

no_content: bool
293    @property
294    def no_content(self) -> bool:
295        """Gets or sets whether tabs contain any content."""
296        return self.tabbar.config.noContent

Gets or sets whether tabs contain any content.

tab_align: str
302    @property
303    def tab_align(self) -> str:
304        """Gets or sets alignment for tabs."""
305        return self.tabbar.config.tabAlign

Gets or sets alignment for tabs.

tab_auto_height: bool
311    @property
312    def tab_auto_height(self) -> bool:
313        """Gets or sets whether the height of tabs is automatically adjusted."""
314        return self.tabbar.config.tabAutoHeight

Gets or sets whether the height of tabs is automatically adjusted.

tab_auto_width: bool
320    @property
321    def tab_auto_width(self) -> bool:
322        """Gets or sets whether the width of tabs is automatically adjusted."""
323        return self.tabbar.config.tabAutoWidth

Gets or sets whether the width of tabs is automatically adjusted.

tab_height: Union[int, str]
329    @property
330    def tab_height(self) -> Union[int, str]:
331        """Gets or sets the height of a tab."""
332        return self.tabbar.config.tabHeight

Gets or sets the height of a tab.

tab_width: Union[int, str]
338    @property
339    def tab_width(self) -> Union[int, str]:
340        """Gets or sets the width of a tab."""
341        return self.tabbar.config.tabWidth

Gets or sets the width of a tab.

views: List[Dict[str, Any]]
347    @property
348    def views(self) -> List[Dict[str, Any]]:
349        """Gets or sets the configuration of tabs."""
350        return self.tabbar.config.views

Gets or sets the configuration of tabs.

def attach( self, id: str, component: Union[str, Any], config: Dict[str, Any] = None) -> Any:
358    def attach(self, id: str, component: Union[str, Any], config: Dict[str, Any] = None) -> Any:
359        """Attaches a DHTMLX component into a Tabbar cell."""
360        return self.tabbar.getCell(id).attach(component, js.JSON.parse(json.dumps(config or {})))

Attaches a DHTMLX component into a Tabbar cell.

def attach_html(self, id: str, html: str) -> None:
362    def attach_html(self, id: str, html: str) -> None:
363        """Adds HTML content into a Tabbar cell."""
364        self.tabbar.getCell(id).attachHTML(html)

Adds HTML content into a Tabbar cell.

def get_cell_parent(self, id: str) -> Any:
366    def get_cell_parent(self, id: str) -> Any:
367        """Returns the parent of a cell."""
368        return self.tabbar.getCell(id).getParent()

Returns the parent of a cell.

def get_cell_widget(self, id: str) -> Any:
370    def get_cell_widget(self, id: str) -> Any:
371        """Returns the widget attached to a Tabbar cell."""
372        return self.tabbar.getCell(id).getWidget()

Returns the widget attached to a Tabbar cell.

class TabbarConfig:
 59class TabbarConfig:
 60    """
 61    Configuration class for Tabbar.
 62    """
 63    def __init__(self,
 64                 views: List[TabConfig],
 65                 activeTab: str = None,
 66                 closable: Union[bool, List[str]] = None,
 67                 css: str = None,
 68                 disabled: Union[str, List[str]] = None,
 69                 mode: str = None,
 70                 noContent: bool = None,
 71                 tabAlign: str = None,
 72                 tabAutoHeight: bool = None,
 73                 tabAutoWidth: bool = None,
 74                 tabHeight: Union[int, str] = None,
 75                 tabWidth: Union[int, str] = None):
 76        """
 77        :param views: (Required) Defines the configuration of tabs.
 78        :param activeTab: (Optional) Sets the currently active tab.
 79        :param closable: (Optional) Adds close buttons for tabs.
 80        :param css: (Optional) The CSS class(es) applied to Tabbar.
 81        :param disabled: (Optional) Makes a tab or tabs disabled.
 82        :param mode: (Optional) Specifies the mode of displaying the tabbar.
 83        :param noContent: (Optional) Defines whether tabs contain any content.
 84        :param tabAlign: (Optional) Sets alignment for tabs.
 85        :param tabAutoHeight: (Optional) Adjusts tab height automatically.
 86        :param tabAutoWidth: (Optional) Adjusts tab width automatically.
 87        :param tabHeight: (Optional) Sets the height of a tab.
 88        :param tabWidth: (Optional) Sets the width of a tab.
 89        """
 90        self.views = views
 91        self.activeTab = activeTab
 92        self.closable = closable
 93        self.css = css
 94        self.disabled = disabled
 95        self.mode = mode
 96        self.noContent = noContent
 97        self.tabAlign = tabAlign
 98        self.tabAutoHeight = tabAutoHeight
 99        self.tabAutoWidth = tabAutoWidth
100        self.tabHeight = tabHeight
101        self.tabWidth = tabWidth
102
103    def to_dict(self) -> Dict[str, Any]:
104        """
105        Converts the TabbarConfig into a dictionary format.
106        """
107        config_dict = {
108            'views': [view.to_dict() for view in self.views],
109            'activeTab': self.activeTab,
110            'closable': self.closable,
111            'css': self.css,
112            'disabled': self.disabled,
113            'mode': self.mode,
114            'noContent': self.noContent,
115            'tabAlign': self.tabAlign,
116            'tabAutoHeight': self.tabAutoHeight,
117            'tabAutoWidth': self.tabAutoWidth,
118            'tabHeight': self.tabHeight,
119            'tabWidth': self.tabWidth
120        }
121        # Remove None values
122        return {k: v for k, v in config_dict.items() if v is not None}

Configuration class for Tabbar.

TabbarConfig( views: List[TabConfig], activeTab: str = None, closable: Union[bool, List[str]] = None, css: str = None, disabled: Union[str, List[str]] = None, mode: str = None, noContent: bool = None, tabAlign: str = None, tabAutoHeight: bool = None, tabAutoWidth: bool = None, tabHeight: Union[int, str] = None, tabWidth: Union[int, str] = None)
 63    def __init__(self,
 64                 views: List[TabConfig],
 65                 activeTab: str = None,
 66                 closable: Union[bool, List[str]] = None,
 67                 css: str = None,
 68                 disabled: Union[str, List[str]] = None,
 69                 mode: str = None,
 70                 noContent: bool = None,
 71                 tabAlign: str = None,
 72                 tabAutoHeight: bool = None,
 73                 tabAutoWidth: bool = None,
 74                 tabHeight: Union[int, str] = None,
 75                 tabWidth: Union[int, str] = None):
 76        """
 77        :param views: (Required) Defines the configuration of tabs.
 78        :param activeTab: (Optional) Sets the currently active tab.
 79        :param closable: (Optional) Adds close buttons for tabs.
 80        :param css: (Optional) The CSS class(es) applied to Tabbar.
 81        :param disabled: (Optional) Makes a tab or tabs disabled.
 82        :param mode: (Optional) Specifies the mode of displaying the tabbar.
 83        :param noContent: (Optional) Defines whether tabs contain any content.
 84        :param tabAlign: (Optional) Sets alignment for tabs.
 85        :param tabAutoHeight: (Optional) Adjusts tab height automatically.
 86        :param tabAutoWidth: (Optional) Adjusts tab width automatically.
 87        :param tabHeight: (Optional) Sets the height of a tab.
 88        :param tabWidth: (Optional) Sets the width of a tab.
 89        """
 90        self.views = views
 91        self.activeTab = activeTab
 92        self.closable = closable
 93        self.css = css
 94        self.disabled = disabled
 95        self.mode = mode
 96        self.noContent = noContent
 97        self.tabAlign = tabAlign
 98        self.tabAutoHeight = tabAutoHeight
 99        self.tabAutoWidth = tabAutoWidth
100        self.tabHeight = tabHeight
101        self.tabWidth = tabWidth
Parameters
  • views: (Required) Defines the configuration of tabs.
  • activeTab: (Optional) Sets the currently active tab.
  • closable: (Optional) Adds close buttons for tabs.
  • css: (Optional) The CSS class(es) applied to Tabbar.
  • disabled: (Optional) Makes a tab or tabs disabled.
  • mode: (Optional) Specifies the mode of displaying the tabbar.
  • noContent: (Optional) Defines whether tabs contain any content.
  • tabAlign: (Optional) Sets alignment for tabs.
  • tabAutoHeight: (Optional) Adjusts tab height automatically.
  • tabAutoWidth: (Optional) Adjusts tab width automatically.
  • tabHeight: (Optional) Sets the height of a tab.
  • tabWidth: (Optional) Sets the width of a tab.
views
activeTab
closable
css
disabled
mode
noContent
tabAlign
tabAutoHeight
tabAutoWidth
tabHeight
tabWidth
def to_dict(self) -> Dict[str, Any]:
103    def to_dict(self) -> Dict[str, Any]:
104        """
105        Converts the TabbarConfig into a dictionary format.
106        """
107        config_dict = {
108            'views': [view.to_dict() for view in self.views],
109            'activeTab': self.activeTab,
110            'closable': self.closable,
111            'css': self.css,
112            'disabled': self.disabled,
113            'mode': self.mode,
114            'noContent': self.noContent,
115            'tabAlign': self.tabAlign,
116            'tabAutoHeight': self.tabAutoHeight,
117            'tabAutoWidth': self.tabAutoWidth,
118            'tabHeight': self.tabHeight,
119            'tabWidth': self.tabWidth
120        }
121        # Remove None values
122        return {k: v for k, v in config_dict.items() if v is not None}

Converts the TabbarConfig into a dictionary format.

class TabConfig:
 5class TabConfig:
 6    """
 7    Configuration class for individual tabs in the Tabbar.
 8    """
 9    def __init__(self,
10                 id: str,
11                 tab: str = None,
12                 tabCss: str = None,
13                 css: str = None,
14                 header: str = None,
15                 html: str = None,
16                 padding: Union[int, str] = None,
17                 tabWidth: Union[int, str] = None,
18                 tabHeight: Union[int, str] = None):
19        """
20        :param id: (Required) The id of the tab.
21        :param tab: (Optional) The name of the tab.
22        :param tabCss: (Optional) The CSS class used for the tab.
23        :param css: (Optional) The CSS class used for the cell.
24        :param header: (Optional) The header of the cell.
25        :param html: (Optional) HTML content for the tab.
26        :param padding: (Optional) The distance between the content and border.
27        :param tabWidth: (Optional) The width of the tab.
28        :param tabHeight: (Optional) The height of the tab.
29        """
30        self.id = id
31        self.tab = tab
32        self.tabCss = tabCss
33        self.css = css
34        self.header = header
35        self.html = html
36        self.padding = padding
37        self.tabWidth = tabWidth
38        self.tabHeight = tabHeight
39
40    def to_dict(self) -> Dict[str, Any]:
41        """
42        Converts the TabConfig into a dictionary format.
43        """
44        config_dict = {
45            'id': self.id,
46            'tab': self.tab,
47            'tabCss': self.tabCss,
48            'css': self.css,
49            'header': self.header,
50            'html': self.html,
51            'padding': self.padding,
52            'tabWidth': self.tabWidth,
53            'tabHeight': self.tabHeight
54        }
55        # Remove None values
56        return {k: v for k, v in config_dict.items() if v is not None}

Configuration class for individual tabs in the Tabbar.

TabConfig( id: str, tab: str = None, tabCss: str = None, css: str = None, header: str = None, html: str = None, padding: Union[int, str] = None, tabWidth: Union[int, str] = None, tabHeight: Union[int, str] = None)
 9    def __init__(self,
10                 id: str,
11                 tab: str = None,
12                 tabCss: str = None,
13                 css: str = None,
14                 header: str = None,
15                 html: str = None,
16                 padding: Union[int, str] = None,
17                 tabWidth: Union[int, str] = None,
18                 tabHeight: Union[int, str] = None):
19        """
20        :param id: (Required) The id of the tab.
21        :param tab: (Optional) The name of the tab.
22        :param tabCss: (Optional) The CSS class used for the tab.
23        :param css: (Optional) The CSS class used for the cell.
24        :param header: (Optional) The header of the cell.
25        :param html: (Optional) HTML content for the tab.
26        :param padding: (Optional) The distance between the content and border.
27        :param tabWidth: (Optional) The width of the tab.
28        :param tabHeight: (Optional) The height of the tab.
29        """
30        self.id = id
31        self.tab = tab
32        self.tabCss = tabCss
33        self.css = css
34        self.header = header
35        self.html = html
36        self.padding = padding
37        self.tabWidth = tabWidth
38        self.tabHeight = tabHeight
Parameters
  • id: (Required) The id of the tab.
  • tab: (Optional) The name of the tab.
  • tabCss: (Optional) The CSS class used for the tab.
  • css: (Optional) The CSS class used for the cell.
  • header: (Optional) The header of the cell.
  • html: (Optional) HTML content for the tab.
  • padding: (Optional) The distance between the content and border.
  • tabWidth: (Optional) The width of the tab.
  • tabHeight: (Optional) The height of the tab.
id
tab
tabCss
css
header
html
padding
tabWidth
tabHeight
def to_dict(self) -> Dict[str, Any]:
40    def to_dict(self) -> Dict[str, Any]:
41        """
42        Converts the TabConfig into a dictionary format.
43        """
44        config_dict = {
45            'id': self.id,
46            'tab': self.tab,
47            'tabCss': self.tabCss,
48            'css': self.css,
49            'header': self.header,
50            'html': self.html,
51            'padding': self.padding,
52            'tabWidth': self.tabWidth,
53            'tabHeight': self.tabHeight
54        }
55        # Remove None values
56        return {k: v for k, v in config_dict.items() if v is not None}

Converts the TabConfig into a dictionary format.