BrowserWidget#

class omni.kit.browser.core.BrowserWidget(
model: AbstractBrowserModel,
style={},
category_delegate=None,
category_width: float = 120,
detail_delegate=None,
min_thumbnail_size: int = 32,
max_thumbnail_size: int = 512,
detail_thumbnail_size: int = 128,
thumbnail_aspect: float = 1.0,
extra_filter_fn: callable = None,
category_tree_mode: bool = False,
overview_delegate=None,
overview_thumbnail_size: int = 192,
overview_thumbnail_aspect: float = 1.0,
overview_thumbnail_padding_width: int = 10,
overview_thumbnail_padding_height: int = 1,
always_select_category: bool = True,
show_category_splitter: bool = False,
splitter_extra_width: int = 4,
show_collection: bool = True,
on_category_selection_changed_fn: Callable[[CategoryItem], None] = None,
extra_ui_style: Dict = {},
multiple_drag: bool = False,
)#

Bases: object

Represents the browser widget, including a collection combobox, a category list view, a detail grid view and a overview grid view (if required) :param model: Data model used by the widget. :type model: BrowserModel

Keyword Arguments:
  • style (dict) – Extra UI style of this widget. Default is empty.

  • category_delegate (CatetoryDelegate) – delegate object to represent category item. Default using CategoryDelegate.

  • category_width (int) – width of category view, in pixel. Default 120.

  • detail_delegate (DetailDelegate) – delegate object to represent detail item. Default using DetailDelegate.

  • min_thumbnail_size (int) – min thumbnail size used in zoom bar. Default 32.

  • max_thumbnail_size (int) – max thumbnail size used in zoom bar. Default 512.

  • detail_thumbnail_size (int) – size of detail item thumbnail, in pixel. Default 128.

  • thumbnail_aspect (float) – Aspect ratio of thumbnail. Default 1.0 (width / height).

  • extra_filter_fn (callable) – Extra filter function called to filter items. Return True to show item otherwise hide. Default None. Function signure: bool extra_filter_fn(item: DetailItem)

  • category_tree_mode (bool) – Show category in tree mode or flat mode. Default flat mode (No branches).

  • overview_delegate (DetailDelegate) – Delegate object to represent item in overview. Default using DetailDelegate.

  • overview_thumbnail_size (int) – size of overview item thumbnail, in pixel. Default 192.

  • overview_thumbnail_aspect (float) – Aspect ratio of overview thumbnail. Default 1.0 (width / height).

  • overview_thumbnail_padding_width (int) – Padding in overview thumbnail width. Default 10.

  • overview_thumbnail_padding_height (int) – Padding in overview thumbnail height. Default 1.

  • always_select_category (bool) – Always select category if collect changed. Default True.

  • show_category_splitter (bool) – Show splitter between category and detail. Default False.

  • splitter_extra_width (int) – Width added to vertical splitter between category view and detail view.

  • show_collection (bool) – True to show collection combobox. Default True.

  • on_category_selection_changed_fn (Callable[[CategoryItem], None]) – Callback when category selection changed.

  • multiple_drag (bool) – True to allow drag multiple items. Default False.

Properties:

collection_index (int): index of selected collection item. Read and write. collection_selection (Optional[Collection]): selected collection item. Readonly. category_selection (List[CategoryItem]): selected category item. Readonly. detail_selection (List[DetailItem]): selected detail item. Readonly.

Methods

__init__(model[, style, category_delegate, ...])

add_filter_changed_fn(on_filter_changed_fn)

Add callback function on filter changed.

add_thumbnail_size_changed_fn(...)

Adds a callback function for thumbnail size changes and returns its identifier.

destroy()

Destroys widget UI components and cleans up callbacks.

filter_details(filter_words)

Filter detail items.

refresh_details()

Refresh detail view for item visibilities.

remove_filter_changed_fn(sub_id)

Remove callback function on filter changed.

remove_thumbnail_size_changed_fn(sub_id)

Removes the callback function for thumbnail size changes using its function identifier.

show_widgets([collection, category, detail])

Show/Hide collection/category/detail widget.

sort_changed()

Notify sort changed.

Attributes

category_selection

Selected category items

collection_index

Gets the index of the selected collection item.

collection_selection

Gets the currently selected collection item.

detail_selection

Selected detail items

model

Model used in this widget

visible

widget visibility

__init__(
model: AbstractBrowserModel,
style={},
category_delegate=None,
category_width: float = 120,
detail_delegate=None,
min_thumbnail_size: int = 32,
max_thumbnail_size: int = 512,
detail_thumbnail_size: int = 128,
thumbnail_aspect: float = 1.0,
extra_filter_fn: callable = None,
category_tree_mode: bool = False,
overview_delegate=None,
overview_thumbnail_size: int = 192,
overview_thumbnail_aspect: float = 1.0,
overview_thumbnail_padding_width: int = 10,
overview_thumbnail_padding_height: int = 1,
always_select_category: bool = True,
show_category_splitter: bool = False,
splitter_extra_width: int = 4,
show_collection: bool = True,
on_category_selection_changed_fn: Callable[[CategoryItem], None] = None,
extra_ui_style: Dict = {},
multiple_drag: bool = False,
)#
add_filter_changed_fn(
on_filter_changed_fn: Callable[[List[str] | None], None],
) int#

Add callback function on filter changed. Return function id used for remove_filter_changed_fn.

Parameters:

on_filter_changed_fn (Callable[[Optional[List[str]]], None]) – Function called when filter changed. Function signature: void on_filter_changed_fn(filter_words: Optional[List[str]])

Returns:

Callback function id.

Return type:

int

add_thumbnail_size_changed_fn(
on_thumbnail_size_changed_fn: Callable[[int], None],
) int#

Adds a callback function for thumbnail size changes and returns its identifier.

Parameters:

on_thumbnail_size_changed_fn (callable) – Function called when thumbnail size changes.

Returns:

Identifier for the added callback function.

Return type:

int

destroy()#

Destroys widget UI components and cleans up callbacks.

This method destroys UI components such as the zoom bar, detail view, and overview view if they exist, and clears registered callbacks.

filter_details(filter_words: List[str] | None)#

Filter detail items.

Parameters:

filter_words (Optional[List[str]]) – A string list to filter detail items. None means filtering nothing.

refresh_details() None#

Refresh detail view for item visibilities.

remove_filter_changed_fn(sub_id: int) None#

Remove callback function on filter changed.

Parameters:

sub_id (int) – Function id from add_filter_changed_fn.

remove_thumbnail_size_changed_fn(sub_id: int) None#

Removes the callback function for thumbnail size changes using its function identifier.

Parameters:

sub_id (int) – Identifier of the callback function to remove.

show_widgets(
collection: bool | None = None,
category: bool | None = None,
detail: bool | None = None,
) None#

Show/Hide collection/category/detail widget. :param collection: True to show collection combobox and False to hide. Default None means no change. :type collection: Optional[bool] :param category: True to show category view and False to hide. Default None means no change. :type category: Optional[bool] :param detail: True to show detail view and False to hide. Default None means no change. :type detail: Optional[bool]

sort_changed() None#

Notify sort changed. Refresh thumbnail view if necessary.

property category_selection: List[CategoryItem]#

Selected category items

property collection_index: int#

Gets the index of the selected collection item.

Returns:

Selected collection index.

Return type:

int

property collection_selection: CollectionItem | None#

Gets the currently selected collection item.

Returns:

Selected collection item, or None if no selection exists.

Return type:

Optional[CollectionItem]

property detail_selection: List[DetailItem]#

Selected detail items

property model: AbstractItemModel#

Model used in this widget

property visible: bool#

widget visibility