log_main_window.py 1.1 KB

1234567891011121314151617181920212223242526272829
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. # bit more complex example set to demo connecting O3DE tech to PySide2 widgets
  7. import azlmbr.bus
  8. from PySide2 import QtWidgets
  9. from PySide2 import QtGui
  10. from shiboken2 import wrapInstance, getCppPointer
  11. params = azlmbr.qt.QtForPythonRequestBus(azlmbr.bus.Broadcast, 'GetQtBootstrapParameters')
  12. if(params is not None and params.mainWindowId != 0):
  13. mainWidgetWindow = QtWidgets.QWidget.find(params.mainWindowId)
  14. mainWindow = wrapInstance(int(getCppPointer(mainWidgetWindow)[0]), QtWidgets.QMainWindow)
  15. mainWindow.menuBar().addMenu("&Hello")
  16. allWindows = QtGui.QGuiApplication.allWindows()
  17. print ('allWindows = {}'.format(allWindows))
  18. focusWin = QtGui.QGuiApplication.focusWindow()
  19. print ('focusWin = {}'.format(focusWin))
  20. buttonFlags = QtWidgets.QMessageBox.information(QtWidgets.QApplication.activeWindow(), 'title', 'ok')
  21. print ('buttonFlags = {}'.format(buttonFlags))