Can't activate file drag and drop on tkinter

Viewed 37

I am currently trying to enable drag and drop files in my tkinter application. This is my code :

# Python 3.10
from tkinter import *
from tkinter.dnd import *


root = Tk()
root.title("DnD Test")
root.geometry("400x400")


path_entry = Entry(root)
path_entry.pack()

def on_dnd(event):
    path_entry.delete(0, END)
    path_entry.insert(0, event.data)

dnd_start(root, on_dnd) # Error here

root.mainloop()

The problem is that this code return me the error AttributeError: 'function' object has no attribute 'num'

So I guess it's not a function that should be put in the second argument of dnd_start but I haven't found what it should be

0 Answers
Related