TKinter file dialag for pluging

MakeHuman python API, python plugins, etc

Moderator: joepal

TKinter file dialag for pluging

Postby faith97 » Mon Oct 24, 2022 3:22 pm

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?
faith97
 
Posts: 1
Joined: Thu Oct 20, 2022 3:56 pm

Re: TKinter file dialag for pluging

Postby joepal » Mon Oct 24, 2022 5:12 pm

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?
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4455
Joined: Wed Jun 04, 2008 11:20 am

Re: TKinter file dialag for pluging

Postby Aranuvir » Mon Oct 24, 2022 9:42 pm

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) ! )
Aranuvir
 
Posts: 1314
Joined: Sun Oct 12, 2014 2:12 pm


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron