lightspeed.trex.utils.widget#

  • SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

  • SPDX-License-Identifier: Apache-2.0

  • Licensed under the Apache License, Version 2.0 (the “License”);

  • you may not use this file except in compliance with the License.

  • You may obtain a copy of the License at

  • https://www.apache.org/licenses/LICENSE-2.0

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an “AS IS” BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  • See the License for the specific language governing permissions and

  • limitations under the License.

class lightspeed.trex.utils.widget.WorkspaceWidget#

Interface for workspace window content widgets. All widgets used in WorkspaceWindowBase should implement this interface.

abstract destroy()#

Clean up all resources, subscriptions, and references. Called when the window is being permanently closed.

show(visible: bool)#

Triggered by the WorkspaceWindowBase when the window is shown or hidden.

Parameters:

visible – True if visible, False if hidden.

property window_visible: bool#

Whether the containing window is currently visible.

class lightspeed.trex.utils.widget.WorkspaceWindowBase(
usd_context_name: str | None = None,
show_dock_tab_bars: bool = True,
)#

Base class with common functionalities for all workspace windows.

cleanup()#

Clean up all window resources. Properly destroys the content widget before cleanup.

create_window(
width: int | None = None,
height: int | None = None,
)#

Creates the ui.Window instance and sets up the “Window” menu item.

abstract property flags: int#

The Window flags integer mask. Check omni.ui.WINDOW_FLAGS_*

menu_path() str | None#

The menu path for this window in the Window menu. None means no menu entry.

abstract property title: str#

The Window title, also used as ID in Kit Workspace

lightspeed.trex.utils.widget.accept_asset_if_valid_for_replacement(
asset_path: str,
layer: Layer,
asset_core: AssetReplacementsCore,
context: UsdContext,
accept_handler: Callable[[str], None],
ignore_ingestion_handler: Callable[[str], None] | None = None,
cancel_handler: Callable[[], None] | None = None,
go_to_ingest_handler: Callable[[], None] | None = None,
) bool#

Accept an asset path or show the shared replacement validation dialogs.

Parameters:
  • asset_path – Selected asset path.

  • layer – Layer the selected asset path is relative to.

  • asset_core – Object exposing asset replacement core validation methods.

  • context – USD context used when copying external assets.

  • accept_handler – Callback receiving the accepted asset path.

  • ignore_ingestion_handler – Optional callback used when the user bypasses ingestion validation.

  • cancel_handler – Optional callback used when the user cancels the validation dialog.

  • go_to_ingest_handler – Optional callback used by the dialog’s ingest action.

Returns:

True if the asset was accepted immediately, False if user input is required.

lightspeed.trex.utils.widget.open_asset_file_picker(
title: str,
asset_type: ReplacementAssetType,
callback: Callable[[str], None],
callback_cancel: Callable[[str], None],
current_file: str | None = None,
fallback: bool = False,
)#

Open the shared asset file picker for a replacement asset type.

Parameters:
  • title – File picker title.

  • asset_type – Asset type accepted by the picker.

  • callback – Callback receiving the selected asset.

  • callback_cancel – Callback invoked when the picker is cancelled.

  • current_file – Optional file or folder to select initially.

  • fallback – Whether the remembered file picker folder should override current_file.

lightspeed.trex.utils.widget.open_replacement_asset_file_picker(
title: str,
unresolved_asset_path: str,
callback: Callable[[str], None],
callback_cancel: Callable[[str], None],
current_file: str | None = None,
)#

Open the shared replacement asset file picker.

Parameters:
  • title – File picker title.

  • unresolved_asset_path – Original unresolved asset path used to choose compatible replacement types.

  • callback – Callback receiving the selected replacement asset.

  • callback_cancel – Callback invoked when the picker is cancelled.

  • current_file – Optional file or folder to select initially.