2010-10-29 72 views
2

的Python 2.7/Windows的:我的理解是,我們可以使用cursor='@file.cur加載自定義鼠標光標」語法:Python/Tkinter:在Windows下使用自定義鼠標光標?

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調用加載自定義鼠標光標?

回答

2

lbl=Label(root, text="toto", cursor="@toto.cur")適用於Python 2.6和Vista。確保cur文件位於腳本的工作目錄中(如果我嘗試加載不存在的遊標,則具有類似的回溯)並且文件未損壞。

作爲替代,這裏是內部的遊標的列表:http://www.tcl.tk/man/tcl8.4/TkCmd/cursors.htm

+0

謝謝呂克。問題原來是試圖從IDLE內運行我的Tkinter代碼(我應該知道更好!)。當我從命令行運行相同的腳本時,cursor='@/path/to/file.ext'技術效果很好。 – Malcolm 2010-10-29 17:10:48