Integrating latest 47acbe8
This commit is contained in:
@@ -20,6 +20,7 @@ from shiboken2 import wrapInstance, getCppPointer
|
||||
# The `view_pane_handlers` holds onto the callback handlers that get created
|
||||
# for responding to requests for when the Editor needs to construct the view pane
|
||||
view_pane_handlers = {}
|
||||
registration_handlers = {}
|
||||
|
||||
# Helper method for registering a Python widget as a tool/view pane with the Editor
|
||||
def register_view_pane(name, widget_type, options=editor.ViewPaneOptions()):
|
||||
@@ -42,7 +43,18 @@ def register_view_pane(name, widget_type, options=editor.ViewPaneOptions()):
|
||||
|
||||
return new_widget.winId()
|
||||
|
||||
# Register our widget as an Editor view pane
|
||||
def on_notify_register_views(parameters, my_name=name, my_options=options):
|
||||
# Register our widget as an Editor view pane
|
||||
print('Calling on_notify_register_views RegisterCustomViewPane')
|
||||
editor.EditorRequestBus(azlmbr.bus.Broadcast, 'RegisterCustomViewPane', my_name, 'Tools', my_options)
|
||||
|
||||
# We keep a handler around in case a request for registering custom view panes comes later
|
||||
print('Initializing callback for RegisterCustomViewPane')
|
||||
registration_handler = azlmbr.bus.NotificationHandler("EditorEventBus")
|
||||
registration_handler.connect()
|
||||
registration_handler.add_callback("NotifyRegisterViews", on_notify_register_views)
|
||||
global registration_handlers
|
||||
registration_handlers[name] = registration_handler
|
||||
editor.EditorRequestBus(azlmbr.bus.Broadcast, 'RegisterCustomViewPane', name, 'Tools', options)
|
||||
|
||||
# Connect to the ViewPaneCallbackBus in order to respond to requests to create our widget
|
||||
|
||||
@@ -11,40 +11,30 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import pathlib
|
||||
import azlmbr
|
||||
import azlmbr.bus
|
||||
|
||||
# establishes python paths to find PySide2 libraries
|
||||
if (azlmbr.qt.QtForPythonRequestBus(azlmbr.bus.Broadcast, 'IsActive')):
|
||||
|
||||
params = azlmbr.qt.QtForPythonRequestBus(azlmbr.bus.Broadcast, 'GetQtBootstrapParameters')
|
||||
|
||||
# add PySide2 base folder to sys.path
|
||||
# Ideally, the current directory or the directory of the script is the first
|
||||
# always the first element: https://tinyurl.com/yysfw8pb
|
||||
sys.path.insert(1, pathlib.PureWindowsPath(params.pySidePackageFolder).as_posix())
|
||||
sys.path.insert(1, pathlib.PureWindowsPath(params.qtBinaryFolder).as_posix())
|
||||
params = azlmbr.qt.QtForPythonRequestBus(azlmbr.bus.Broadcast, 'GetQtBootstrapParameters')
|
||||
|
||||
if len(params.qtPluginsFolder):
|
||||
# add the Qt plugins to the environment
|
||||
os.environ['QT_PLUGIN_PATH'] = params.qtPluginsFolder
|
||||
|
||||
# add Qt binaries to the Windows path to handle findings DLL file dependencies
|
||||
if sys.platform.startswith('win'):
|
||||
path = os.environ['PATH']
|
||||
newPath = ''
|
||||
newPath += params.qtBinaryFolder + os.pathsep
|
||||
newPath += os.path.join(params.pySidePackageFolder, 'shiboken2') + os.pathsep
|
||||
newPath += os.path.join(params.pySidePackageFolder, 'PySide2') + os.pathsep
|
||||
newPath += path
|
||||
os.environ['PATH'] = newPath
|
||||
print('PySide2 bootstrapped PATH for Windows.')
|
||||
# add Qt binaries to the Windows path to handle findings DLL file dependencies
|
||||
if len(params.qtBinaryFolder) and sys.platform.startswith('win'):
|
||||
path = os.environ['PATH']
|
||||
newPath = ''
|
||||
newPath += params.qtBinaryFolder + os.pathsep
|
||||
newPath += path
|
||||
os.environ['PATH'] = newPath
|
||||
print('PySide2 bootstrapped PATH for Windows.')
|
||||
|
||||
# Once PySide2 has been bootstrapped, register our Object Tree visualizer with the Editor
|
||||
try:
|
||||
import az_qt_helpers
|
||||
from show_object_tree import ObjectTreeDialog
|
||||
az_qt_helpers.register_view_pane('Object Tree', ObjectTreeDialog)
|
||||
except:
|
||||
print ('Skipping register our Object Tree visualizer with the Editor.')
|
||||
# Once PySide2 has been bootstrapped, register our Object Tree visualizer with the Editor
|
||||
try:
|
||||
import az_qt_helpers
|
||||
from show_object_tree import ObjectTreeDialog
|
||||
az_qt_helpers.register_view_pane('Object Tree', ObjectTreeDialog)
|
||||
except:
|
||||
print('Skipping register our Object Tree visualizer with the Editor.')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user