FileBrowserGridViewDelegate

class omni.kit.widget.filebrowser.grid_view.FileBrowserGridViewDelegate(widget: Frame, theme: str, **kwargs)

Bases: object

The delegate that manages building browser items under the model as widgets inside the grid view.

Parameters
  • ( (widget) – obj: `ui.Frame`): The frame for the delegate to build widgets under.

  • theme (str) – The theme name to use.

Keyword Arguments
  • mouse_pressed_fn (Callable) – Function called on mouse press. Function signature: void mouse_pressed_fn(button: int, key_mode: int, item: FileBrowserItem, x: float=0, y: float=0)

  • mouse_double_clicked_fn (Callable) – Function called on mouse double click. Function signature: void mouse_double_clicked_fn(button: int, key_mode: int, item: FileBrowserItem, x: float=0, y: float=0)

  • selection_changed_fn (Callable) – Function called when selection changed. Function signature: void selection_changed_fn(selections: list[FileBrowserItem])

  • drop_fn (Callable) – Function called to handle drag-n-drops. Function signature: void drop_fn(dst_item: FileBrowserItem, src_path: str)

  • thumbnail_provider (Callable) – This callback returns the path to the item’s thumbnail. If not specified, then a default thumbnail is used. Signature: str thumbnail_provider(item: FileBrowserItem).

  • badges_provider (Callable) – This callback provides the list of badges to layer atop the thumbnail in the grid view. Callback signature: List[str] badges_provider(item: FileBrowserItem)

  • treeview_identifier (str) – widget identifier for treeview, only used by tests.

  • testing (bool) – When enabled, forces items to immediately be built and made available.

Methods

__init__(widget, theme, **kwargs)

add_selection(card)

Add a new card to selection.

build_card(model, item)

Create a widget per item.

build_grid(model)

Build browser items under the model.

center_selection_async(selection[, ...])

Center the given item and add it to the selection.

clear_selections()

Clear current selection.

destroy()

Destructor.

extend_selections(cards)

Extend current selection.

refresh_thumbnails_async(urls)

Re-generate the thumbnails with given URLs.

remove_selection(card)

Remove a new card from the selection.

update_cards_on_thumbnails_generated(event)

When new thumbnails are generated, re-renders associated cards.

update_grid(model)

Generate a grid of cards and renders them with custom thumbnails.

Attributes

scale

Get the scale of items.

selections

Get the current selection.

__init__(widget: Frame, theme: str, **kwargs)
add_selection(card: FileBrowserItemCard)

Add a new card to selection.

Parameters

card (FileBrowserItemCard) – Item widget to add.

build_card(model: FileBrowserModel, item: FileBrowserItem) FileBrowserItemCard

Create a widget per item.

Parameters
  • model (FileBrowserModel) – model to build the item with.

  • item (FileBrowserItem) – the item to build the widget.

build_grid(model: FileBrowserModel)

Build browser items under the model.

Parameters

model (FileBrowserModel) – Model containing items to build.

async center_selection_async(selection: FileBrowserItem, scroll_frame: Optional[Frame] = None, scroll_ratio=0.0, refresh_interval=2, callback: Optional[Callable[[FileBrowserItem], None]] = None)

Center the given item and add it to the selection.

Parameters
  • selection (FileBrowserItem) – Item to center on.

  • scroll_frame (ui.Frame) – Optional argument frame to scroll to the item’s new position.

  • scroll_ratio (float) – Optional argument ratio to scroll to the item’s new position using item index ratio.

clear_selections()

Clear current selection.

destroy()

Destructor.

extend_selections(cards: List[FileBrowserItemCard])

Extend current selection.

Parameters

cards (List[FileBrowserItemCard]) – List of item widgets to extend.

async refresh_thumbnails_async(urls: str)

Re-generate the thumbnails with given URLs.

Parameters

urls (List[str]) – thumbnail URLs to update.

remove_selection(card: FileBrowserItemCard)

Remove a new card from the selection.

Parameters

card (FileBrowserItemCard) – Item widget to remove.

update_cards_on_thumbnails_generated(event: IEvent)

When new thumbnails are generated, re-renders associated cards.

Parameters

events (IEvent) – event containing the thumbnail URLs to update.

update_grid(model: FileBrowserModel)

Generate a grid of cards and renders them with custom thumbnails.

Parameters

model (FileBrowserModel) – Model containing items to update.

property scale: float

Get the scale of items.

property selections: List[FileBrowserItem]

Get the current selection.