Packaging panda3d in tkinter GUI (Python)

Hey,
Im trying to package my Software via pyinstaller. Its a Panda3d showbase embedded inside an tkinter GUI. The Problem is, panda3d uses Pmw(Python mega widgets) when beeing embedded in tkinter and I just cant manage to make pmw beeing correctly packaged by pyinstaller, since it has its problems with pmw. On the Pmw page seems to be a solution, which packages the whole Pmw library into a single “.py”. (http://pmw.sourceforge.net/doc/dynamicloader.html) See “freezing” on the bottom of the page
But it doesnt Explain, what to explicitly do With that afterwards.

How would I go on from this point to make the packaging work? (–hiddenimport is not a solution!)
Is there another solution to make this work? (although I would prefer to package it via pyinstaller)

Have you tried using Panda’s tools for distributing applications (build_apps and bdist_apps)? I’m pretty sure it supports tkinter, but I am not sure if Pmw has been tested.

Well, im Probably going to use matplotlib and numpy, too. And im planning to use some more exotic libraries like cartopy. Im not Sure how far the setuptools from Panda3d go but im going to Try it.

But there has to be a Solution regarding Pmw (showbase initiates the tkRoot from Pmw, is there a specific reason why it is Using Pmw and not tkinter to start the tkRoot?)

I tried the setuptools approach, but using “python setup.py build_apps” results in pip(?) not finding Pmw (and several other dependencies) while when manually installing them via the requirements.txt it works fine…

I also tried now to rewrite direct.showbase.Showbase to not use Pmw when beeing handed over to Tkinter. But even after commenting out everything “Pmw-related” and replacing imports with Tkinter.Tk(), after compiling the Code, it tells me that Pmw is missing. Am I missing something?

I found a solution, I had to rewrite the output of the .py generated by the script delivered by Pmw. Now everthing Pmw related seems to be fine, but when I compile the program and try to start it, the output of the console says:

Warning: unable to auto-locate config files in directory named by "<auto>etc".
:audio: NullAudioManager
:audio: NullAudioManager
Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
  File "earth.py", line 409, in <module>
    app = Application(windowType = 'none')
  File "earth.py", line 210, in __init__
    self.makeDefaultPipe()
  File "lib\site-packages\direct\showbase\ShowBase.py", line 584, in makeDefaultPipe
  File "lib\site-packages\direct\directnotify\Notifier.py", line 130, in error
Exception: No graphics pipe is available!
Your Config.prc file must name at least one valid panda display
library via load-display or aux-display.
[36476] Failed to execute script earth

after adding the /etc/ folder of Panda3d with COnfig.prc I still get:

:audio(error):   load_dso(libp3openal_audio.so) failed, will use NullAudioManager
:audio(error):     Path not found
:display(warning): Unable to load: Path not found
Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
  File "earth.py", line 409, in <module>
    app = Application(windowType = 'none')
  File "earth.py", line 210, in __init__
    self.makeDefaultPipe()
  File "lib\site-packages\direct\showbase\ShowBase.py", line 584, in makeDefaultPipe
  File "lib\site-packages\direct\directnotify\Notifier.py", line 130, in error
Exception: No graphics pipe is available!
Your Config.prc file must name at least one valid panda display
library via load-display or aux-display.
[36368] Failed to execute script earth

edit:
PyInstaller seems to miss out on some important DLL’s. I manually copied missing DLL’s from the Library directory and it works now.

edit edit:
the problem seems to occur totally random, now even with copying the DLL’s its throwing the same error again

edit edit edit:
nvm, was probably some problem with my venv, I deleted it and build a new venv

okay everything works fine now. But while reading through direct.showbase.Showbase and altering the code to make it work without Pmw, I realised, that Pmw is literally used nowhere else or am I wrong? I changed the code of Showbase to use tkinter.Tk() instead of Pmw.initialise() and it works just fine inside my tk embedding. Pmw is known to cause issues when trying to freeze an application and could be thrown completly out of the dependencies for Panda3D.

As for why Pmw is a dependency, many of the things in Direct that use Tkinter rely on Pmw, and Pmw wants to control the Tkinter initialisation. It could not be simply thrown out.