Using a custom file browser
Users can use their custom file browsers when browsing for Atoms files. This allows different pipelines to use their own internal DB browsers.
In order to register a new browser callback you have override the Atoms.ui.utils.qt.open_file_browser method.
The arguments of the browser callback are:
parent: the parent widget
title: the title of the browser as requested by Atoms
dir: the current directory
filter: the file filter
directory_mode: if true, we are browsing for a directory
save_mode: if true, we are saving a file
hint: this string will provide info about the specific task the user is performing.
The possible value for the hint argument are:
load_state_machine_json, save_state_machine_json (State machine)
load_animation_clip_script, save_animation_clip_script (Animation clips)
load_agent_type_script, save_agent_type_script (Agent types)
load_behaviour_module_script, save_behaviour_module_script (Behaviour modules)
load_simulation_event_script, save_simulation_event_script (Simulation events)
load_variation, save_variation, merge_variation (Variation json)
material (load_only), texture (load_only), atoms_geo (load_only) (Variation elements)
cloth_setup (load_only) (Cloth setup)
atoms_cache_path (load_only) (Atoms cache)
atoms (load_only) (Skeleton config map)
Example
from Atoms.ui.utils.qthandler import QtGui, QtCore, QtWidgets
import Atoms.ui.utils.qt
def my_open_file_browser(parent, title, dir="", filter="*", directory_mode=False, save_mode=False, hint=None):
fn = None
if directory_mode:
if save_mode:
fn = QtWidgets.QFileDialog.getExistingDirectory(parent, "MY_BROWSER " + title, dir)
else:
fn = QtWidgets.QFileDialog.getExistingDirectory(parent, "MY_BROWSER " + title, dir)
else:
if save_mode:
fn = QtWidgets.QFileDialog.getSaveFileName(parent, "MY_BROWSER " + title, dir, filter)
else:
fn = QtWidgets.QFileDialog.getOpenFileName(parent, "MY_BROWSER " + title, dir, filter)
return fn
Atoms.ui.utils.qt.open_file_browser = my_open_file_browser