Python Tkinter DnD2 root = TkinterDnD.Tk() 无法加载 tkdnd 库 [英] Python Tkinter DnD2 root = TkinterDnD.Tk() Unable to load tkdnd library

查看:30
本文介绍了Python Tkinter DnD2 root = TkinterDnD.Tk() 无法加载 tkdnd 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照此处的说明安装了 TkDnD:如何在 OSX 上通过 Python 2.7 Tkinter 安装和使用 TkDnD?

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

主要是我遵循了这个建议:

Mainly i followed this advice:

在 Windows 上:

On Windows:

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

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

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

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

我正在使用 anaconda,所以我将它复制到我的环境目录 (C:\ProgramData\Anaconda3\envs\gui)

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()

我收到此错误

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

认为这是 anaconda 的问题,我也在我的系统 Python 中安装了 TkDnD(没有虚拟环境),但问题仍然存在.有什么想法吗?

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 二进制文件.

Try installing the tkdnd binary matching your python installation (64 bit or 32 bit).

这篇关于Python Tkinter DnD2 root = TkinterDnD.Tk() 无法加载 tkdnd 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆