1
votes

I have a Python 2.7/Tkinter program that uses TkinterDnD2 and TkDnD (not part of the standard Python distribution) to provide file drag-and-drop in a Win7/Win10 environment. I have been using PyInstaller to create a single-file executable for ease of distribution within our organization. I hadn't touched it for a few years, but it's needing maintenance. Unfortunately, the current version of PyInstaller (3.2) does not produce a working executable with these Tk* modules. (I have a custom arcane hook-_tkinter.py that made it work with an older version of PyInstaller, but have not been able to port it to 3.2.)

I could try replacing PyInstaller; I could try a different GUI toolkit. I would like a solution that will work in Python 3. I need the file drag-and-drop capability. It's not clear whether the TkinterDnD2 and TkDnD are being supported any more.

What would be a viable combination of packages to build a Python 3 GUI with file drag-and-drop and distribute as a "portable" executable?

Python 3 + [tkinter|wxwidgets|pyside|??] + [pyinstaller|cx_freeze|py2exe|??]

1
Have you tried py2exe? There is a lot you can do to customize packaging up your code base and including external files. - Dan
@Dan I have not tried py2exe yet. However, my PyInstaller success/failure was very dependent on which Python modules I was using, so, since there are a large number of combinations of GUIs + packagers, I was hoping to benefit from some collective wisdom to narrow down the choices. - notsofast
Take a look at py2exe and specifically look at the includes option: py2exe.org/index.cgi/ListOfOptions - Dan

1 Answers

0
votes

I have successfully migrated my application to Python 3.4/PySide 1.2.4/Qt 4.8.7 running in Windows 10, and I can successfully package it into a single-file .exe with PyInstaller 3.2.

The packaging is much more straightforward than it was with Python 2.7 and Tkinter/TkinterDnD2/TkDnD. No custom hooks are needed:

pyi-makespec --windowed --onefile --noupx --icon=appicon.ico app.py
pyinstaller --clean app.spec

This produces app.exe. I use the --clean flag to clear out the pyinstaller cache each time to avoid any problems.

I am also very happy with Qt/PySide. It has solid support for drag-and-drop (which was my requirement from above), a mature set of widgets, and good documentation.

I also looked at the other GUI toolkit candidates, Tkinter and wxwidgets. Tkinter in Python 3 still does not support file drag-and-drop natively, and it did not look like TkinterDnD/TkDnD was being actively supported. Wxwidgets did not appear to support file drag-and-drop either.