Reference Viewer dialog example
Create a reference_viewer_dialog.py file inside your user extensions folder with the following content:
Please check the dialog extension section to know more.
from PySide2 import QtWidgets
from ftrack_framework_qt.dialogs import BaseContextDialog
from ftrack_utils.framework.config.tool import get_plugins
class ReferenceViewerDialog(BaseContextDialog):
name = "reference_viewer_dialog"
ui_type = 'qt'
def __init__(
self,
event_manager,
client_id,
connect_methods_callback,
connect_setter_property_callback,
connect_getter_property_callback,
dialog_options,
parent=None,
):
super(ReferenceViewerDialog, self).__init__(
event_manager,
client_id,
connect_methods_callback,
connect_setter_property_callback,
connect_getter_property_callback,
dialog_options,
parent=parent,
)
self.setWindowTitle("Hello World")
self.resize(400, 200)
def pre_build_ui(self):
layout = QtWidgets.QVBoxLayout()
self.setLayout(layout)
def build_ui(self):
label = QtWidgets.QLabel("Hello World Dialog")
self.layout().addWidget(label)
self._button = QtWidgets.QPushButton("Close")
self.layout().addWidget(self._button)
for tool_config in self.tool_configs:
if tool_config.get('name') in self.tool_config_names:
# Found the matching tool config
self.tool_config = tool_config
break
# Build hello world collector widgets
reference_collector_plugins = get_plugins(
self.tool_config, filters={'tags': ['collector']}
)
for reference_collector_plugin in reference_collector_plugins:
if not reference_collector_plugin.get('ui'):
continue
reference_collector_widget = self.init_framework_widget(reference_collector_plugin)
self.layout().addWidget(reference_collector_widget)
def post_build_ui(self):
self._button.clicked.connect(self.close)