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(...)

Add callback function on thumbnail size changed.

destroy()

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 chagned.

remove_thumbnail_size_changed_fn(sub_id)

Remove callback function on thumbnail size chagned.

show_widgets([collection, category, detail])

Show/Hide collection/category/detail widget.

sort_changed()

Notify sort changed.

Attributes

category_selection

Selected category items

collection_index

collection_selection

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 fuction id used for remove_filter_changed_fn. :param on_filter_changed_fn: Function called when filter changed. Function signature: void on_filter_changed_fn(filter_words: Optional[List[str]]) :type on_filter_changed_fn: callable

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

Add callback function on thumbnail size changed. Return function id used for remove_thumbnail_size_changed_fn. :param on_thumbnail_size_changed_fn: Function called when thumbnail size changed. Function signature: void on_thumbnail_size_changed_fn(thumbnail_size: int) :type on_thumbnail_size_changed_fn: callable

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

Filter detail items. :param filter_words: 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 chagned. :param sub_id: Function id, comes from add_filter_changed_fn.

remove_thumbnail_size_changed_fn(sub_id: int) None#

Remove callback function on thumbnail size chagned. :param sub_id: Function id, comes from add_thumbnail_size_changed_fn.

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 detail_selection: List[DetailItem]#

Selected detail items

property model: AbstractItemModel#

Model used in this widget

property visible: bool#

widget visibility