How to add GUI elements into the window using PySide2/Qt

How do I add sliders, Radio buttons, and other UI elements that inter act with the Panda3d environment, that are in Qt into Panda3D? Is it possible? are there any other ways to insert aforementioned UI elements.

For example, If I have a Sphere in the environment loaded,

  1. By changing the slider UI element the sphere radius changes, or
  2. The color will be changed or
  3. The texture changes by the help of drop down option.

Thanks in advance.

yes and mmmaybe

yes: if all you need is a local build (e.g: python3 my_app.py) , you can do it with QPanda3d (though I had to rewrite my mouse, keyboard, and scrollwheel handling)

mmmaybe: I was never able to get a runnable .app out of python3 setup.py bdist_apps. (Other things came up so I didn’t spend too much time on it.)

Pyinstaller says they support Qt5 without any issues, so maybe this just comes down to finding a good sample of building a panda app with pyinstaller

I was able to build a fairly complex app using QPanda3d and PyQt5 and pyinstaller.

Does QPanda3d has mouse support? According to the Github it doesn’t, which would be a blocking issue for me.

I don’t recall having any issue to implement camera control, zoom, pan and drawing some lines using QPanda3d.

any chance you’d be willing to share a “hello pandaQT+pyinstaller” example?

I’ll open it since I’ll move to javascript frontend. if you have any doubts, message me.

1 Like
# A hook for qpanda3d
# Author : Saifeddine ALOUI
# Description : A hook to enable compiling a QPanda3d app using Pyinstaller
# Please refer to /doc/build_project_using_pyinstaller.md
# Notice, this hook can also be used to build a panda3d app using pyinstaller

from PyInstaller.utils.hooks import collect_submodules
from PyInstaller.utils.hooks import collect_data_files
from PyInstaller.utils.hooks import collect_dynamic_libs

print(" -------- Adding panda3d hook ------------")

hiddenimports = collect_submodules('panda3d')
datas = collect_data_files('panda3d')
binaries = collect_dynamic_libs('panda3d')

not quite there . Took a bit to get it to pick up config files and .dylibs for opengl, but now that the package looks okay, we get a segfault without error messages.

same path to get there and same instacrash with plain panda3d project or with qpanda3d.

Once I get it dialed in, II’ll make a minimal panda3d+pyinstaller example with a setup_pyinstaller.py, and then move on to a panda3d+qt+pyinstaller example.

command line version:

python3 -m PyInstaller --additional-hooks-dir pyinstaller_hooks \
 qtpan2.py \
--add-data etc:etc \
--add-data qml:qml \
 --add-binary extralib:.
spec version (collapsed)
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(['qtpan2.py'],
             pathex=['<path omittted>/pandatest'],
             binaries=[('extralib', '.')],
             datas=[('etc', 'etc'), ('qml', 'qml')],
             hiddenimports=[],
             hookspath=['pyinstaller_hooks'],
             hooksconfig={},
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)

exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='qtpan2',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True,
          disable_windowed_traceback=False,
          target_arch=None,
          codesign_identity=None,
          entitlements_file=None )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               upx_exclude=[],
               name='qtpan2')

% dist/qtpan2/qtpan2      
qml: LOADER SwitchDelegate_QMLTYPE_0_QML_2(0x7f8a17146cd0) {"objectName":"","name":"single_cluster","type":"<class 'bool'>","value":false,"fullpath":"DesignOptions.single_cluster","path":"DesignOptions","meta":{}}
Known pipe types:
  CocoaGraphicsPipe
(all display modules loaded.)
zsh: segmentation fault  dist/qtpan2/qtpan2
%

(good news: QML is running and doing my console.log() statements. bad news: segfault, with or withotu Qt)