Inertial scrolling in Mac OS X with Tkinter and Python

半世苍凉 提交于 2019-11-30 17:47:16

These errors can be caught:

while True:
    try:
        root.mainloop()
        break
    except UnicodeDecodeError:
        pass

This seems to work perfectly, even scrolling inertially, and does not require any installation/upgrading.

This looks like the problem described here. If you are using the python.org 64-bit/32-bit installer for 3.3 (currently 3.3.2), make sure you've also installed the latest ActiveTcl release, currently 8.5.13, as noted here.

Neptune798, It should work. Apparently this bug has resurfaced in ActiveTcl 8.6. It's definitely a bug with Tk, as I encountered the same issue testing with Python 3.4.4, 3.5.4, and 3.6.2. All of them reported using the Tcl/Tk libraries installed in:

**/System**/Library/Frameworks/Tcl.framework/Versions/8.5/ 

I encountered this bug with ActiveTcl 8.6.6 specifically, and after downgrading to 8.5.18.0 it went away. Checking what Python was using after the downgrade, it reported:

>>> import tkinter
>>> root = tkinter.Tk()
>>> print(root.tk.exprstring('$tcl_library'))
/Library/Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts
>>> print(root.tk.exprstring('$tk_library'))
/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts

Notice it's finding ActiveTcl in just /Library now, not /System/Library

Although they do not offer old releases for download any longer, I was able to find an old link that still works here

With Python 3.7, Tcl/Tk is being bundled with Python, and tkinter is no longer relying on the system's Tcl/Tk version. I've tested both the CPython release, and the Anaconda release, and both work fine with the bundled Tcl/Tk 8.6 included.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!