I want to drop a file on tkinter and get its path [Tkinter DnD2]

I feel like I can do it.

It is a faucet. I'm not usually an engineer or anything. I don't really need it, but the windows on the street Usually when I drop a file, I feel like it's doing something about it.

Tkinter also looked like "I can do it". Well, if you drop the file normally, nothing happens.

This time, it wasn't listed on Qiita (maybe I just didn't find it) I decided to post it here so that I don't have to take the same steps in the future.

environment

Windows10 64bit python3.7

TkinterDnD2 Apparently, by using TkinterDnD2 in addition to Tkinter It seems that you will be able to receive the dropped files.

Then, why not just "pip install" as usual? I thought.

ERROR: Could not find a version that satisfies the requirement tkinterdnd2 (from versions: none)
ERROR: No matching distribution found for tkinterdnd2```

 it did not work out.

## Installation of TkinterDnD2
 After surfing the internet, I finally arrived at this site.
 I somehow downloaded the newer one from [here](https://sourceforge.net/projects/tkinterdnd/files/TkinterDnD2/).

 When you unzip the downloaded file, you will find a lot of files.
 This is a mess. What should I do?

 If you surf the internet again
 __ "Put the TkinterDnD2 folder in your site-packages folder" __.

 There was certainly a folder called __ "TkinterDnD2" __ in the unzipped one.
 I see, move this to site-packages ...
 I stopped at that point.
 __ Where are those site-packages? __

## I don't know the location of site-packages
 I remember that site-packages is the place where people who get somehow pip install are placed.
 And I've actually been there several times, but honestly I couldn't remember anything.

 Again I surfed the internet.
 I was able to get the path to site-packages by running the following command at the command prompt.
 Thank you, internet.
 [Thank you Tonks! ](Https://qiita.com/jaguti/items/be36b6a4f0260be2d044)

 1. Start "Run" with Windows key + R
 2. Type cmd and click "OK"
3.python -c "import site; print (site.getsitepackages())"

## After all, I can't!
 I thought I was finally able to drag and drop after a hard time
 I couldn't get an error normally.
 Apparently, in addition to TkinterDnD2, you need __tkDnD2__.

 tk seems to be an abbreviation, but apparently these two are completely different things.
 Java and JavaScript are completely different things, and I want you to stop doing that.

## Installation of tkDnD2
 From [here](https://sourceforge.net/projects/tkdnd/files/Windows%20Binaries/TkDND%202.8/), "tkdnd2.8-win32-x86_64.tar.gz" that should be compatible with 64bit I downloaded it.
 It was an unseen type of compression called a gz file, but Lhaplus easily decompressed it.
 When I unzipped it, I got a lot of files again.

 This time, it seems that everything will be copied to the following folder.
 __ (Omitted) \ Programs \ Python \ Python37 \ tcl \ tkdnd__
 It already existed up to tcl.
 I didn't have tkdnd, so I created it myself.

## I got the path of the dropped file!
 ![uma.gif](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/311431/2a6ec25c-9ea0-24b5-b604-15074789b45f.gif)
 This time I got the path of the video and tried to draw it on the canvas.
 It doesn't seem to be of any use as it is, but it seems to make sense to combine it with something.


Recommended Posts

I want to drop a file on tkinter and get its path [Tkinter DnD2]
I want to log file I / O on Linux
I want to write to a file with Python
I want to get the path of the directory where the running file is stored.
I want to make a music player and file music at the same time
I want to write an element to a file with numpy and check it.
I want to get the file name, line number, and function name in Python 3.4
I want to find a popular package on PyPi
I want to randomly sample a file in Python
I get "too early to create image" on tkinter
[Python] I want to get a common set between numpy
I want to record the execution time and keep a log.
Scraping and tabelog ~ I want to find a good restaurant! ~ (Work)
I want to create a pipfile and reflect it in docker
I want to hack Robomaster S1 ① Rooting and file configuration check
I want to get information from fstab at the ssh connection destination and execute a command
I want to create a histogram and overlay the normal distribution curve on it. matplotlib edition
I want to extract the tag information (title and artist) of a music file (flac, wav).
[Python Kivy] How to get the file path by dragging and dropping
[Python memo] I want to get a 2-digit hexadecimal number from a decimal number
I want to build a Python environment
I want to use Linux on mac
I want to receive the configuration file and check if the JSON file generated by jinja2 is a valid JSON
Get the path to the systemd unit file
I want to format and check Python code to my liking on VS Code
I want to develop Android apps on Android
I want to make a web application using React and Python flask
I want to pass an argument to a python function and execute it from PHP on a web server
I have a private Python package but I want to install pipenv on GitHub Actions and build a Docker Image
I want to output a path diagram of distributed covariance structure analysis (SEM) by linking Python and R.
I want to display only different lines of a text file with diff
Try to get a web page and JSON file using Python's Requests library
I just want to add scipy, but it's a messy note. Ubuntu, Python 3.
I want to add silence to the beginning of a wav file for 1 second
I want to exe and distribute a program that resizes images Python3 + pyinstaller
I want to convert horizontal text to vertical text and post it on Twitter etc.
I want to make matplotlib a dark theme
I want to easily create a Noise Model
I want to create a window in Python
I want to make a game with Python
I don't want to take a coding test
I want to get League of Legends data ③
I want to get League of Legends data ②
I want to create a plug-in type implementation
I want to do pyenv + pipenv on Windows
I made a tool to get new articles
I want to easily find a delicious restaurant
I want to get League of Legends data ①
I want to upload a Django app to heroku
I want to use a python data source in Re: Dash to get query results
Every time I try to read a csv file using pandas, I get a numpy error.
[Pyhton] I want to solve the problem that tkinter does not work on MacOS11
I want to save a file with "Do not compress images in file" set in OpenPyXL
I want to take a screenshot of the site on Docker using any font
I want to replace the variables in the python template file and mass-produce it in another file.
I want to write a triple loop and conditional branch in one line in python
[Memorandum] ① Get and save tweets ~ I want to identify the news tweets that are spread ~
I want to see the file name from DataLoader
I want to embed a variable in a Python string
I want to easily implement a timeout in python
I want to iterate a Python generator many times