问题描述
Python 2.7/Windows:我的理解是,我们可以使用cursor='@file.cur'语法加载自定义鼠标光标:
Python 2.7/Windows: My understanding is that we can load custom mouse cursors using the cursor='@file.cur' syntax:
widget = tkinter.Label( ..., cursor='@help.cur' )
这是我收到的回溯信息:
Here's the traceback I receive:
Traceback (most recent call last):
File "<pyshell#82>", line 1, in <module>
widget.config( cursor='@help.cur' )
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1202, in configure
return self._configure('configure', cnf, kw)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1193, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
TclError: bad cursor spec "@help.cur"
是否可以使用Tkinter,Tkinter扩展或通过Win32 API调用在Windows下加载自定义鼠标光标?
Is it possible to load custom mouse cursors under Windows using Tkinter, a Tkinter extension, or via a Win32 API call?
推荐答案
lbl=Label(root, text="toto", cursor="@toto.cur")
在Python 2.6和Vista上对我有效.确保cur文件位于脚本的工作目录中(如果尝试加载不存在的游标,则具有类似的回溯),并且文件未损坏.
lbl=Label(root, text="toto", cursor="@toto.cur")
works for me on Python 2.6 and Vista. Make sure that the cur file is in the working directory of your script (I have a similar traceback if I try to load a non-existing cursor) and that the file is not corrupted.
作为替代方案,下面是内部游标的列表: http: //www.tcl.tk/man/tcl8.4/TkCmd/cursors.htm
As an alternative, here is a list of internal cursors: http://www.tcl.tk/man/tcl8.4/TkCmd/cursors.htm
这篇关于Python/Tkinter:在Windows下使用自定义鼠标光标吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!