Python/Tkinter:在 Windows 下使用自定义鼠标光标?

发布于 2024-09-30 02:13:12 字数 726 浏览 0 评论 0原文

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"

Is it possible to load custom mousecursors under Windows using Tkinter, a Tkinter extension,或者通过 Win32 API 调用?

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"

Is it possible to load custom mouse cursors under Windows using Tkinter, a Tkinter extension, or via a Win32 API call?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林很绿却致人迷途 2024-10-07 02:13:12

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

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

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.

As an alternative, here is a list of internal cursors: http://www.tcl.tk/man/tcl8.4/TkCmd/cursors.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文