【问题标题】:Python/Tkinter: Using custom mouse cursors under Windows?Python/Tkinter:在 Windows 下使用自定义鼠标光标?
【发布时间】:2010-10-29 06:46:04
【问题描述】:

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"

是否可以在 Windows 下使用 Tkinter、Tkinter 扩展或通过 Win32 API 调用加载自定义鼠标光标?

【问题讨论】:

    标签: python user-interface icons tkinter


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢你,卢克。问题原来是试图从 IDLE 中运行我的 Tkinter 代码(我应该更清楚!)。当我从命令行运行相同的脚本时,cursor='@/path/to/file.ext' 技术效果很好。
    • 有没有办法在 tkinter 中使用 ani 扩展光标
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-13
    • 1970-01-01
    • 2011-07-29
    • 2010-12-25
    相关资源
    最近更新 更多