问题描述
我花了一些时间来寻找可行的解决方案,以在OSX平台上使用Python Tkinter进行拖放行为,发现的最可能的解决方案是TkDnD库. http://sourceforge.net/projects/tkdnd/files/
I've spent some time to search for workable solution to do Drag and Drop behavior with Python Tkinter on OSX platform, and the most possible solution found is TkDnD library.http://sourceforge.net/projects/tkdnd/files/
但是我找不到关于安装的任何手册或指南,并且在OSX上基本上没有样本.谁能和我分享他们的经验?
However I cannot find any manual or guide about the installation and basically no sample on OSX. Can anyone share their experience with me?
此外,使用Tkinter作为GUI解决方案不是一个很好的选择吗?我的用户都是OSX平台,并且所有这些计算机上均已预装Python.在没有其他安装的情况下找到本机GUI支持的任何好建议? PyQT似乎是另一种选择,但不确定是否需要在客户端计算机上进行其他安装.
Furthermore, is it not a good choice to use Tkinter as a GUI solution? My users are all OSX platform and Python is preinstalled on all these machines. Any good suggestion to find a native GUI support without additional installation? PyQT seems to be another choice, but not sure if it requires the additional installation on Client machine.
推荐答案
我花了几天时间弄清楚如何安装TkDnD lib,尽管这听起来像是一个简单的问题,但确实让我有些困惑.
I spent a few days to figured out how to install TkDnD lib, although it sounds like an easy question but did confused me a little while.
在OSX上安装TkDnD的两种方法: A.复制到/System/Library/Tcl/8.x
:OSX已经预装了Python,这是Tcl库的安装路径.使用Tk/Tcl库时,将自动加载TkDnd库.
Two ways to install TkDnD on OSX:A. Copy to /System/Library/Tcl/8.x
:OSX preinstalled Python already, and this is the path where Tcl library is installed. TkDnd lib will be loaded automatically while using Tk/Tcl lib.
B.将os.environ['TKDND_LIBRARY']
设置为TkDnd2.x.dylib的位置:示例代码:
B. Set os.environ['TKDND_LIBRARY']
to the location of TkDnd2.x.dylib:Sample code:
if sys.platform == 'win32':
if getattr(sys, 'frozen', False):
os.environ['TKDND_LIBRARY'] = os.path.join(os.path.dirname(sys.executable), 'tkdnd2.7')
这篇关于如何在OSX上通过Python Tkinter安装和使用TkDnD?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!