I’m trying to help the owner of tkdnd generate a wheel and distribute it to Pypi so users could simply install the tkdnd extension with a simple pip install TkinterDnD2
.
I’m after this ‘challange’ for the last two days but could not solve it by myself so far, but I’m sure someone with a deep understanding python packaging and installing process could help as solve it in short time.
currently in order to get this extension work you need to do the following steps(as mentioned here):
- download the compiled tkdnd files for your os. now go to your base interpreter directory/tcl and copy this folder under. for example:
--<python3.9-directory> --tcl --tkdnd2.9.2 ... ...
notice – it did not work for me if I created a matching tcl/tkdnd2.9.2 directory in the venv of the project the imported TkinterDnD2
- now download the python wrapper and add it you your venv site-packages directory(or base interpreter it’s doesn’t matter). so the python project which will import TkinterDnD2 will look like this:
--<python-test-project> --venv --Lib --site-packages --TkinterDnD2 ... ...
now one could successfully run tkdnd extensions.
you can probably tell this is not much like installing the average python library. the problematic thing here is that the extra tkdnd2.9.2 folder is required to be in the tcl folder of your base interpreter.
maybe it is possible to use the package_data
and data_files
in the setup.py to tell python to add this tcl files during the installation from the wheel, but I’m not sure. see Packaging and distributing projects
for full reference.
the incomplete setup.py:
import setuptools with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() setuptools.setup( name="TkinterDnD2", version="2.9.2", author="petasis", description="TkDND is an extension that adds native drag & drop capabilities to the Tk toolkit.", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/petasis/tkdnd", project_urls={ "Bug Tracker": "https://github.com/petasis/tkdnd/issues", }, classifiers=[ "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Operating System :: OS Independent", ], packages=setuptools.find_packages(), python_requires=">=2, >=3", # some extra logic probably belong here # ... )
you can track the issue here which includes some extra discussions.
very helpful stackoverflow questions:
- How to avoid building C library with my python package?
- How to Install and Use TkDnD with Python Tkinter on OSX?
very helpful guides:
- Packaging and distributing projects
- Packaging Python Projects
- Python Bindings: Calling C or C++ From Python
any help would be very appreciated!
Advertisement
Answer
Just answering for the case someone else got stuck on it for weeks like I did.
You can see dist repo that pmgagne created here: https://github.com/pmgagne/tkinterdnd2
The package is not yet published on pypi but you can build a wheel and install it following the instructions on this issue I opened: https://github.com/pmgagne/tkinterdnd2/issues/5
Hopefully, the author will build and publish it soon, so you could simply do python -m pip install tkinterdnd2
and enjoy tkinter inter-windows drag and drop support!
If you don’t want to build it your self here’s a wheel download: tkinterdnd2-0.3.0-py2.py3-none-any.zip
extract zip and then you can do python -m pip install tkinterdnd2-0.3.0-py2.py3-none-any.whl
and then you will be able to import tkinterdnd2
in your python project.
UPDATE
the author did not respond so I forked it published it myself. you can now install simply using
pip install tkinterdnd2
enjoy!