Inertial scrolling in Mac OS X with Tkinter and Python

前端 未结 3 1444
有刺的猬
有刺的猬 2021-01-04 05:54

I am working on a Python 3.3 project that uses Tkinter as a Window manager. I have mouse scroll wheel events set up for a canvas. The scrolling works in Windows 7, 8, and Ub

相关标签:
3条回答
  • 2021-01-04 06:04

    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.

    0 讨论(0)
  • 2021-01-04 06:14

    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.

    0 讨论(0)
  • 2021-01-04 06:27

    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.

    0 讨论(0)
提交回复
热议问题