简体   繁体   English

Python Tkinter DnD2 root = TkinterDnD.Tk() 无法加载 tkdnd 库

[英]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?我按照此处的说明安装了 TkDnD: How to Install and Use TkDnD with Python 2.7 Tkinter on OSX?

Mainly i followed this advice:主要是我遵循了这个建议:

On Windows:在 Windows 上:

1) Copy the tkdnd2.8 directory to C:\\Python27\\tcl 1)将tkdnd2.8目录复制到C:\\Python27\\tcl

2) Copy the TkinterDnD2 directory to C:\\Python27\\Lib\\site-packages 2)将TkinterDnD2目录复制到C:\\Python27\\Lib\\site-packages

I am using anaconda so I copied it into my environments directories (C:\\ProgramData\\Anaconda3\\envs\\gui)我正在使用 anaconda,所以我将它复制到我的环境目录中 (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.认为这是 anaconda 的问题,我也在我的系统 Python 中安装了 TkDnD(没有虚拟环境),但问题仍然存在。 Any ideas ?有任何想法吗 ?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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