简体   繁体   中英

Python Tkinter DnD2 root = TkinterDnD.Tk() Unable to load tkdnd library

I installed TkDnD as instructed here: How to Install and Use TkDnD with Python 2.7 Tkinter on OSX?

Mainly i followed this advice:

On Windows:

1) Copy the tkdnd2.8 directory to C:\\Python27\\tcl

2) Copy the TkinterDnD2 directory to C:\\Python27\\Lib\\site-packages

I am using anaconda so I copied it into my environments directories (C:\\ProgramData\\Anaconda3\\envs\\gui)

And yet when i try to run this code:

import sys
if sys.version_info[0] == 2:
    from Tkinter import *
else:
    from tkinter import *
from TkinterDnD2 import *

def drop(event):
    entry_sv.set(event.data)

root = TkinterDnD.Tk()
entry_sv = StringVar()
entry_sv.set('Drop Here...')
entry = Entry(root, textvar=entry_sv, width=80)
entry.pack(fill=X, padx=10, pady=10)
entry.drop_target_register(DND_FILES)
entry.dnd_bind('<<Drop>>', drop)
root.mainloop()

I get this error

Exception has occurred: RuntimeError
Unable to load tkdnd library.
  File "drag_and_drop_GUI.py", line 10, in <module>
    root = TkinterDnD.Tk()

Thinking it's a problem with anaconda I installed TkDnD in my system Python too (no virtual environments) but the issue still persists. Any ideas ?

尝试安装与您的 python 安装(64 位或 32 位)匹配的 tkdnd 二进制文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM