gpt4 book ai didi

Python/Tkinter : Using custom mouse cursors under Windows?

转载 作者:行者123 更新时间:2023-12-03 03:03:37 25 4
gpt4 key购买 nike

Python 2.7/Windows:我的理解是我们可以使用cursor='@file.cur'语法加载自定义鼠标光标:

widget = tkinter.Label( ..., cursor='@help.cur' )

这是我收到的回溯:

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 下加载自定义鼠标光标?

最佳答案

lbl=Lab​​el(root, text="toto",cursor="@toto.cur") 适用于 Python 2.6 和 Vista。确保 cur 文件位于脚本的工作目录中(如果我尝试加载不存在的游标,我会有类似的回溯)并且该文件未损坏。

作为替代方案,这里是内部游标列表:http://www.tcl.tk/man/tcl8.4/TkCmd/cursors.htm

关于Python/Tkinter : Using custom mouse cursors under Windows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4049612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com