omni.flux.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
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.
- omni.flux.utils.widget.background_pattern.create_widget_with_pattern(
- widget: Callable | partial,
- background_name: str,
- v_pattern_loop: int = 3,
- h_pattern_loop: int = 3,
- image_size: int = 256,
- height: Length | None = None,
- width: Length | None = None,
- background_margin: Tuple[int, int] | None = None,
- pattern_image_name: str = 'TreePanelLinesBackground',
- pattern_background_rectangle_name: str = 'WorkspaceBackground',
- widget_margin: Tuple[int, int] | None = None,
Create a widget with a pattern as a background
- Parameters:
widget – the function that will create the widget, like ui.Widget
background_name – the name of the rectangle used as a background of the widget
v_pattern_loop – the number of time the pattern will loop vertically
h_pattern_loop – the number of time the pattern will loop horizontally
image_size – the size of the pattern image
height – the height of the whole ui widget
width – the width of the whole ui widget
background_margin – margin of the whole ui widget
pattern_image_name – image name to use for the pattern
pattern_background_rectangle_name – image name to use for the background rectangle of the pattern
widget_margin – margin of the given widget to create
- Returns:
the created widget given by the “widget” arg
- Return type:
ui.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
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.
- omni.flux.utils.widget.button.create_button_from_widget(
- widget: Widget,
- on_clicked: Callable[[float, float, int, int], None],
Sets the mouse pressed/hovered/release button events to the given widget to give it button behavior.
- Parameters:
widget – Widget that will have events added to it.
on_clicked – (optional) method that is fired with same arguments as ui.Widget.set_mouse_pressed_fn callback
- omni.flux.utils.widget.button.create_button_with_custom_font(
- text: str,
- text_style_name: str,
- rectangle_style_name: str,
- height: Length,
- height_padding: Length,
- pressed_fn: Callable | None = None,
Create a button with a text that has a custom font
- Parameters:
text – the text to show
text_style_name – the style name of the text label
rectangle_style_name – the style name of the background rectangle
height – the height of the button
height_padding – padding between the top of the button, the text, and the bottom
pressed_fn – function that will be called when the button if pressed
- Returns:
The image ui widget that contains the text and the background rectangle ui widget
- omni.flux.utils.widget.button.create_button_with_label_style(
- text: str,
- text_style_name: str,
- rectangle_style_name: str,
- on_clicked: Callable[[float, float, int, int], None] | None = None,
Create a button with a text that have a custom style
- Parameters:
text – the text to show
text_style_name – the style name of the text label
rectangle_style_name – the style name of the background rectangle
on_clicked – (optional) method that is fired with same arguments as ui.Widget.set_mouse_pressed_fn callback
- Returns:
The label ui widget and the background rectangle ui 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
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 omni.flux.utils.widget.collapsable_frame.PropertyCollapsableFrame(
- title: str,
- collapsed: bool = False,
- show_info_icon: bool = False,
- pinnable: bool = False,
- pinned_text_fn: Callable[[], str] | None = None,
- unpinned_fn: Callable[[], None] | None = None,
- enabled: bool = True,
Bases:
object
- destroy()#
- property enabled#
- get_info_widget() Image #
Get the info widget
- Returns:
The info widget
- property pinned#
- property root#
- class omni.flux.utils.widget.collapsable_frame.PropertyCollapsableFrameWithInfoPopup(
- *args,
- info_text: str = '',
- pinnable: bool = False,
- **kwargs,
Bases:
PropertyCollapsableFrame
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
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.
- omni.flux.utils.widget.color.color_to_hex(
- color: Tuple[float, float, float, float | None],
Convert float rgb to int
- omni.flux.utils.widget.color.hex_to_color(hex_value: int) Tuple[int, int, int, int] #
Convert hex to RGBA
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
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.
- omni.flux.utils.widget.gradient.create_gradient(
- width: int,
- height: int,
- values1: Tuple[int, ...],
- values2: Tuple[int, ...],
- is_horizontal_list: Tuple[bool, ...],
Create a gradient (like a RGBA) of any dimension
- Parameters:
width – width of the gradient
height – height of the gradient
values1 – start values (like (0, 0, 0, 255)) of the gradient. Work with any dimension.
values2 – end values (like (255, 255, 255, 255)) of the gradient. Work with any dimension.
is_horizontal_list – horizontal or vertical gradient (like (True, True, True, True))
- Returns:
The gradient values
- omni.flux.utils.widget.gradient.create_gradient_1d(
- width: int,
- height: int,
- int1: int,
- int2: int,
- is_horizontal: bool,
Create a 1d gradient
- Parameters:
width – width of the gradient
height – height of the gradient
int1 – start number of the gradient, like 0
int2 – end number of the gradient, like 255
is_horizontal – horizontal or vertical gradient
- Returns:
The 1d gradient
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
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 omni.flux.utils.widget.hover.CursorShapesEnum(value)#
Bases:
Enum
Enumeration of the cursor shapes.
Provides a simpler way for developers to define their desired cursor shape, since carb.windowing.CursorStandardShape is not a standard Python Enum - it’s a binding.
- ARROW = <CursorStandardShape.ARROW: 0>#
- CROSSHAIR = <CursorStandardShape.CROSSHAIR: 2>#
- HAND = <CursorStandardShape.HAND: 3>#
- HORIZONTAL_RESIZE = <CursorStandardShape.HORIZONTAL_RESIZE: 4>#
- IBEAM = <CursorStandardShape.IBEAM: 1>#
- VERTICAL_RESIZE = <CursorStandardShape.VERTICAL_RESIZE: 5>#
- class omni.flux.utils.widget.hover.CursorStandardShape#
Bases:
pybind11_object
Members:
ARROW
IBEAM
CROSSHAIR
HAND
HORIZONTAL_RESIZE
VERTICAL_RESIZE
- ARROW = <CursorStandardShape.ARROW: 0>#
- CROSSHAIR = <CursorStandardShape.CROSSHAIR: 2>#
- HAND = <CursorStandardShape.HAND: 3>#
- HORIZONTAL_RESIZE = <CursorStandardShape.HORIZONTAL_RESIZE: 4>#
- IBEAM = <CursorStandardShape.IBEAM: 1>#
- VERTICAL_RESIZE = <CursorStandardShape.VERTICAL_RESIZE: 5>#
- property name#
- property value#
- omni.flux.utils.widget.hover.hover_helper(
- widget: Widget,
- cursor_shape: CursorStandardShape | None = None,
Adds hover actions for the specified widget.
The cursor will change to the cursor shape passed to the __init__() function, with a default of HAND. The shape must be one of the shapes defined in carb.windowing.CursorStandardShape; these are:
ARROW
CROSSHAIR
HAND
HORIZONTAL_RESIZE
IBEAM
VERTICAL_RESIZE
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
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.
- omni.flux.utils.widget.label.create_label_with_font(
- text: str,
- style_name: str,
- remove_offset: bool = True,
- offset_divider: int = 1,
- max_width: int = 0,
- max_height: int = 0,
- custom_image_height: Length | None = None,
- font_size_multiply: float = 1.0,
- deferred: bool = False,
- multiline_if_max_width: bool = True,
- tooltip: str | None = None,
- quality_multiplier: int = 2,
- ext_name: str | None = None,
- rotation: Rotation | None = None,
Create a label with a custom font
- Parameters:
text – the text to show
style_name – the style name of the text label used with an ui.ImageWithProvider
remove_offset – remove the offset on the top and left of the text
offset_divider – divide the offset length on the top and left of the text
max_width – the max width of the final widget
max_height – the max height of the final widget
custom_image_height – set a custom height of the final widget
font_size_multiply – multiply the font size by this number
deferred – build the widget async
multiline_if_max_width – if max_width is specify and the text is longer, create a multiline
tooltip – tool tip to add on the widget
quality_multiplier – internal multiplier of the text size to have a better quality
ext_name – the name of the resource extension. If not specify, /exts/omni.flux.utils.widget/default_resources_ext setting will be used.
rotation – rotate the text or not
- Returns:
The image provider, the image, and the task if “deferred” is True
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
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 omni.flux.utils.widget.loader.Loader(
- style_name: str = 'Hourglass',
- width: Length = 16,
- height: Length = 16,
Bases:
object
- destroy()#
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
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.
- omni.flux.utils.widget.resources.get_background_images(
- ext_name: str | None = None,
Get background image from a resource extension
- Parameters:
name – the name of the background image to get (without the extension)
ext_name – the name of the resource extension. If not specify, /exts/omni.flux.utils.widget/default_resources_ext setting will be used.
- Returns:
Path of the background image
- omni.flux.utils.widget.resources.get_font_list(ext_name: str | None = None) Dict[str, str] #
Get font list from a resource extension
- Parameters:
ext_name – the name of the resource extension. If not specify, /exts/omni.flux.utils.widget/default_resources_ext setting will be used.
- Returns:
Dictionary with the name of the font and the font path
- omni.flux.utils.widget.resources.get_fonts(name: str, ext_name: str | None = None) str | None #
Get font from a resource extension
- Parameters:
name – the name of the font to get (without the extension)
ext_name – the name of the resource extension. If not specify, /exts/omni.flux.utils.widget/default_resources_ext setting will be used.
- Returns:
Path of the font
- omni.flux.utils.widget.resources.get_icons(name: str, ext_name: str | None = None) str | None #
Get icon from a resource extension
- Parameters:
name – the name of the icon to get (without the extension)
ext_name – the name of the resource extension. If not specify, /exts/omni.flux.utils.widget/default_resources_ext setting will be used.
- Returns:
Path of the icon
- omni.flux.utils.widget.resources.get_image(name: str, ext_name: str | None = None) str | None #
Get image from a resource extension
- Parameters:
name – the name of the image to get (without the extension)
ext_name – the name of the resource extension. If not specify, /exts/omni.flux.utils.widget/default_resources_ext setting will be used.
- Returns:
Path of the image
- omni.flux.utils.widget.resources.get_test_data(name: str, ext_name: str | None = None) str | None #
Get test data from a resource extension
- Parameters:
name – the name of the data to get (without the extension). Can be “hello.usd” or “hello/hello.usd”
ext_name – the name of the resource extension. If not specify, /exts/omni.flux.utils.widget/default_resources_ext setting will be used.
- Returns:
Path of test data
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
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 omni.flux.utils.widget.search.AbstractSearchItem#
Bases:
object
AbstractSearchItem represents a single file in the file browser.
- property date#
- property icon#
- property is_folder#
- property name#
The name as it appears in the widget
- property path#
The full path that goes to usd when Drag and Drop
- property size#
- class omni.flux.utils.widget.search.AbstractSearchModel#
Bases:
object
AbstractSearchModel represents the search results. It supports async mode. If the search engine needs some time to process the request, it can return an empty list and do a search in async mode. As soon as a result is ready, the model should call self._item_changed(). It will make the view reload the model. It’s also possible to return the search result with portions.
__init__ is usually called with the named arguments search_text and current_dir, and optionally a search_lifetime object.
- destroy()#
Called to cancel current search
- abstract property items#
Should be implemented
- subscribe_item_changed(fn)#
Return the object that will automatically unsubscribe when destroyed.
- class omni.flux.utils.widget.search.FileBrowserItem(
- path: str,
- fields: FileBrowserItemFields,
- is_folder: bool = False,
- is_deleted: bool = False,
Bases:
AbstractItem
Base class for the Filebrowser view Item. Should be sub-classed to implement specific filesystem behavior. The Constructor should not be called directly. Instead there are factory methods available for creating instances when needed.
- Parameters:
path (str) – Path of the item.
fields (
FileBrowserItemFields
) – Fields of the item.is_folder (bool) – Set to True if the item is a folder.
is_deleted (bool) – Set to True if the item is deleted.
- add_child(item: object)#
Add item as child.
- Parameters:
item (
FileBrowserItem
) – Child item.
- property alert: Tuple[int, str]#
Get/set alert level and message.
- property children: Dict[str, FileBrowserItem]#
Children of this item. Does not populate the item if not already populated.
- Type:
dict[
FileBrowserItem
]
Optionally provide a context menu to be show when this item is right-clicked.
- del_child(item_name: str)#
Delete child item by name.
- Parameters:
item_name (str) – Name of child item.
- property enable_sorting: bool#
True if item’s children are sortable.
- Type:
bool
- property expandable: bool#
whether this FileBrowserItem is expandable. Override to change behavior
- property fields: FileBrowserItemFields#
A subset of the item’s stats stored as a string tuple.
- Type:
FileBrowserItemFields
- async get_custom_thumbnails_for_folder_async() Dict #
Return the thumbnail dictionary for this (folder) item.
- Returns:
With children url’s as keys, and url’s to thumbnail files as values.
- Return type:
Dict
- get_subitem_model(index: int) object #
Return ith column of this item.
- Returns:
AbstractValueModel
- has_mouse_pressed_fn()#
Check if the item has a mouse pressed callback assigned.
- property hideable: bool#
whether this FileBrowserItem is hideable. Override to change behavior
- property icon: str#
Get/set path to icon file.
- Type:
str
- property is_deleted: bool#
True if this item is a deleted folder/file.
- Type:
bool
- property is_folder: bool#
True if this item is a folder.
- Type:
bool
- property is_udim_file: bool#
Get/Set item udim_file state.
- Type:
bool
- property item_changed: bool#
True if this item is has been restore/delete aready.
- Type:
bool
- property models: Tuple#
The columns of this item.
- Type:
Tuple[
ui.AbstractValueModel
]
- mouse_pressed_fn()#
Mouse pressed callback.
- property name: str#
Item name.
- Type:
str
- on_list_change_event(
- event: ListEvent,
- entry: ListEntry,
Virtual method to be implemented by sub-class. When called with a ListEvent, should update this item’s children list with the corresponding ListEntry.
- Parameters:
event (
omni.client.ListEvent
) – One of of {UNKNOWN, CREATED, UPDATED, DELETED, METADATA, LOCKED, UNLOCKED}.entry (
omni.client.ListEntry
) – Updated entry as defined by omni.client.
- async on_populated_async(
- result=None,
- children: Dict[str, FileBrowserItem] | None = None,
- callback: Callable[[Dict[str, FileBrowserItem]], None] | None = None,
async callback after finish populating the item.
- Parameters:
result (Any) – result from populate async.
children (Dict[str,
FileBrowserItem
]) – dictionary of children items to pass to the callback.callback (Callable) – function to call.Function signature: callback(result: Any, children: Dict[str, FileBrowserItem]) -> None
- property parent: object#
Parent of this item.
- Type:
- property path: str#
Full path name.
- Type:
str
- async populate_async(
- callback_async: Callable | None = None,
- timeout: float = 10.0,
Populate current item asynchronously if not already. Override this method to customize for specific file systems.
- Parameters:
callback_async (Callable) – Function signature is void callback(result, children: Dict[str, FileBrowserItem]), where result is an Exception type upon error.
timeout (float) – Time out duration on failed server connections. Default 10.0.
- Returns:
Result of executing callback.
- Return type:
Any
- populate_with_callback(
- callback: Callable,
- timeout: float = 10.0,
Populate this item if not already populated. When done, executes callback.
- Parameters:
callback (Callable) – Function signature is void callback(children: [FileBrowserItem]).
timeout (float) – Time out duration on failed server connections. Default 10.0.
- property populated: bool#
Get/Set item populated state.
- Type:
bool
- property readable: bool#
True if the item is readable.
- static size_as_string(value: int) str #
Convert data size in bytes to a human readable string.
- update_permissions(
- new_permissions: AccessFlags,
Update item’s permissions.
- Parameters:
new_permissions( – obj:’omni.client.AccessFlags’): New permissions to this item.
- property writeable: bool#
True if the item is writeable.
- omni.flux.utils.widget.search.SearchEngineRegistry(*args, **kwargs)#
- class omni.flux.utils.widget.search.SearchItem(
- dir_path: str,
- file_entry: ListEntry,
Bases:
AbstractSearchItem
- property date: str#
- property is_folder: bool#
- property name: str#
The name as it appears in the widget
- property path: str#
The full path that goes to usd when Drag and Drop
- property size: str#
- class omni.flux.utils.widget.search.SearchModel(
- search_text: str | None = None,
- current_dir: str | None = None,
- search_lifetime: str | None = None,
Bases:
AbstractSearchModel
- destroy()#
Called to cancel current search
- property items: list[SearchItem]#
Should be implemented
- omni.flux.utils.widget.search.create_search_widget(
- callback: Callable[[str], None],
Create a widget with an input field to be able to do search
- Parameters:
callback – the function that will be called when the used input a character in the field
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
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 omni.flux.utils.widget.text_to_image.Rotation(value)#
Bases:
Enum
An enumeration.
- LEFT_90 = 'Left90'#
- RIGHT_90 = 'Right90'#
- omni.flux.utils.widget.text_to_image.generate_image_from_text(
- text: str,
- font_path: str,
- size: int,
- remove_offset: bool = True,
- offset_divider: int = 1,
- max_width: int = 0,
- max_height: int = 0,
- size_multiplier: float = 1,
- multiline_if_max_width: bool = True,
- ext_name: str | None = None,
- rotation: Rotation | None = None,
Generate an image from a text
- Parameters:
text – the text to show
font_path – the font path
size – the size of the font to use
remove_offset – if True, it will remove the padding at the top of the font
offset_divider – to add more padding at the top
max_width – max width of the final text
max_height – max height of the final text
size_multiplier – multiply the font size
multiline_if_max_width – if the text is bigger than the max width, do multiline or not
ext_name – the name of the resource extension. If not specify, /exts/omni.flux.utils.widget/default_resources_ext setting will be used.
rotation – rotate the text or not
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
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.
- omni.flux.utils.widget.file_pickers.file_picker.destroy_file_picker(*args)#
- omni.flux.utils.widget.file_pickers.file_picker.open_file_picker(
- title,
- callback: Callable[[str | List[str]], None],
- callback_cancel: Callable[[str | List[str]], None],
- apply_button_label: str | None = None,
- current_file: str | None = None,
- fallback=False,
- file_extension_options: List[Tuple[str, str]] | None = None,
- select_directory: bool = False,
- validate_selection: Callable[[str, str], bool] | Callable[[List[str]], bool] | None = None,
- validation_failed_callback: Callable[[str, str], None] | Callable[[List[str]], None] | None = None,
- bookmarks: Dict[str, str] | None = None,
- allow_multi_selection: bool = False,
Open a file picker
- Parameters:
title – title of the window
callback – function to execute when the user clicks on the select button. If allow_multi_selection is True, the input arg is a list of paths
callback_cancel – function to execute when the user clicks on the cancel button. If allow_multi_selection is True, the input arg is a list of paths
apply_button_label – The string to display in the “apply” button
current_file – current file to select when the window is opened. If unset, the file browser will open at the last known directory
fallback – if True and if the file picker has a current folder, a default folder will be shown when the window is opened
file_extension_options –
A list of filename extension options. Each list element is an (extension name, description) pair.
Examples:
(“*.usdc”, “Binary format”) or (“.usd*”, “USD format”) or (“*.png, *.jpg, *.exr”, “Image format”)
# noqaselect_directory – whether the file picker is used to select a directory or a file
validate_selection – function to execute to validate the selected file/directory. If false, the window file will not be selected. If allow_multi_selection is True, the callback will take a list of file
validation_failed_callback – function to call if the selection validation returns False. If allow_multi_selection is True, the callback will take a list of file
bookmarks – Bookmarks to add to the file picker in the format { name: path }
allow_multi_selection – Allow multi file selection in picker
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
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 omni.flux.utils.widget.tree_widget.delegate.AlternatingRowDelegate(
- row_height: int,
- scrollbar_spacing: bool = True,
Bases:
AbstractItemDelegate
- build_branch(
- self: omni.ui._ui.AbstractItemDelegate,
- model: omni.ui._ui.AbstractItemModel,
- item: omni.ui._ui.AbstractItem = None,
- column_id: int = 0,
- level: int = 0,
- expanded: bool = False,
This pure abstract method must be reimplemented to generate custom collapse/expand button.
- build_widget(
- self: omni.ui._ui.AbstractItemDelegate,
- model: omni.ui._ui.AbstractItemModel,
- item: omni.ui._ui.AbstractItem = None,
- index: int = 0,
- level: int = 0,
- expanded: bool = False,
This pure abstract method must be reimplemented to generate custom widgets for specific item in the model.
- property default_attr: dict[str, None]#
- destroy()#
- class omni.flux.utils.widget.tree_widget.delegate.TreeDelegateBase#
Bases:
AbstractItemDelegate
- DEFAULT_IMAGE_ICON_SIZE = 24.000000px#
- build_branch(
- model: _TreeModelBase,
- item: _TreeItemBase,
- column_id: int,
- level: int,
- expanded: bool,
Create a branch widget that opens or closes the subtree. To define the build function, override _build_branch.
- build_header(column_id: int)#
Create a header at the top of the tree. To define the build function, override _build_header.
- build_widget(
- model: _TreeModelBase,
- item: _TreeItemBase,
- column_id: int,
- level: int,
- expanded: bool,
Create a widget per item. To define the build function, override _build_widget. This function wraps the widget in a frame with an on-click listener.
- abstract property default_attr: dict[str, None]#
- destroy()#
- property selection: list[_TreeItemBase]#
Get the currently selected items
- function: Callable[[_TreeModelBase, _TreeItemBase], None],
Return the object that will automatically unsubscribe when destroyed.
- subscribe_item_clicked(
- function: Callable[[bool, _TreeModelBase, _TreeItemBase], None],
Return the object that will automatically unsubscribe when destroyed.
- subscribe_item_expanded(function)#
Return the object that will automatically unsubscribe when destroyed.
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
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 omni.flux.utils.widget.tree_widget.item.AlternatingRowItem(index: int)#
Bases:
AbstractItem
- property alternate: bool#
- property default_attr: dict[str, None]#
- destroy()#
- class omni.flux.utils.widget.tree_widget.item.TreeItemBase(children: list[TreeItemBase] | None = None)#
Bases:
AbstractItem
- abstract property can_have_children: bool#
- property children: list[TreeItemBase]#
- abstract property default_attr: dict[str, None]#
- destroy()#
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
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 omni.flux.utils.widget.tree_widget.model.AlternatingRowModel#
Bases:
AbstractItemModel
- abstract property default_attr: dict[str, None]#
- destroy()#
- get_item_children(
- self: omni.ui._ui.AbstractItemModel,
- parentItem: omni.ui._ui.AbstractItem = None,
Returns the vector of items that are nested to the given parent item.
### Arguments:
- id :
The item to request children from. If it’s null, the children of root will be returned.
- get_item_value_model_count(
- self: omni.ui._ui.AbstractItemModel,
- item: omni.ui._ui.AbstractItem = None,
Returns the number of columns this model item contains.
- refresh(item_count: int)#
- class omni.flux.utils.widget.tree_widget.model.TreeModelBase#
Bases:
AbstractItemModel
,Generic
[T
]- can_item_have_children(
- self: omni.ui._ui.AbstractItemModel,
- parentItem: omni.ui._ui.AbstractItem = None,
Returns true if the item can have children. In this way the delegate usually draws +/- icon.
### Arguments:
- id :
The item to request children from. If it’s null, the children of root will be returned.
- abstract property default_attr: dict[str, None]#
- destroy()#
- iter_items_children(
- items: Iterable[T] | None = None,
- recursive=True,
Iterate through a collection of items’ children
- Parameters:
items – The collection of items to get children from
recursive – Whether to get the children recursively or only the direct children
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
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 omni.flux.utils.widget.tree_widget.widget.AlternatingRowWidget(
- header_height: int,
- row_height: int,
- scrollbar_spacing: bool = True,
- model: AlternatingRowModel | None = None,
- delegate: AlternatingRowDelegate | None = None,
Bases:
object
- destroy()#
- refresh(item_count: int = 0)#
Refresh the widget whenever the number of items in the foreground tree changes.
- Parameters:
item_count – The number of items in the foreground tree
- sync_frame_height(frame_height: float)#
Sync the frame height to make sure the entire frame is filled with alternating row backgrounds.
- Parameters:
frame_height – The height of the frame this widget should fill.
- sync_scrolling_frame(position: float)#
Sync the scroll position whenever the foreground tree’s scroll position changes.
- Parameters:
position – The new scroll position
- class omni.flux.utils.widget.tree_widget.widget.TreeWidget(
- model: _TreeModelBase,
- delegate: _TreeDelegateBase,
- select_all_children: bool = True,
- validate_action_selection: bool = True,
- **kwargs,
Bases:
TreeView
- abstract property default_attr: dict[str, None]#
- destroy(self: omni.ui._ui.Widget) None #
Removes all the callbacks and circular references.
- iter_visible_children(items=None, recursive: bool = True)#
Iterate through expanded children of items
- Parameters:
items – The collection of items to get children from
recursive – Whether to get the children recursively or only the direct children
- on_selection_changed(items: list[_TreeItemBase])#
Function to be called whenever the tree widget selection widget changes (set_selection_changed_fn).
The base implementation selects children when selecting a parent if _select_all_children is True
- Parameters:
items – The list of items selected
- subscribe_selection_changed(
- callback: Callable[[list[_TreeItemBase]], None],