Page 1 of 1

TKinter file dialag for pluging

PostPosted: Mon Oct 24, 2022 3:22 pm
by faith97
Hi, I'm trying to use the python module TKinter to add a filedialog to my plugin. Unfortunately the makehuman log file tells me that the program is not able to find tkinter module even though it is installed in my pc. There is a way I can include it in my project?

Re: TKinter file dialag for pluging

PostPosted: Mon Oct 24, 2022 5:12 pm
by joepal
It's a bit tricky if you use the python that is bundled with makehuman. You could try to add tk to the python directory in the installation location, but my guess is this might be cumbersome.

If you run from source instead of from a build, your system python will be used.

I know this might not be a very useful suggestion, but the GUI system bundled with MakeHuman is PyQT. Maybe a workaround would be to reformulate the tk parts into the qt corresponding ones?

Re: TKinter file dialag for pluging

PostPosted: Mon Oct 24, 2022 9:42 pm
by Aranuvir
I'm curious if it would be possible to set up pip and install tk from the 'shell' tab inside of MakeHuman.
Maybe these code snippets are inspiring:
Code: Select all
import ensurepip
ensurepip.bootstrap(root=None, upgrade=False, user=False, altinstall=False, default_pip=False, verbosity=0)
It might be necessary to change some of the function parameters. The Documentation is here: https://docs.python.org/3/library/ensurepip.html

and

Code: Select all
import sys
import subprocess

# implement pip as a subprocess:
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
'<packagename>'])
Idea is from this page: https://www.activestate.com/resources/q ... -a-script/

However, I fear in the end TKinter will fail to create its graphics context from inside an OpenGL-Application, if it ever will install. Joel's suggestion to go for Qt is definitely your better choice. (BTW, in case you are going for Qt, do not mix PyQt and Pyside(=Qt for Python) ! )