Reputation: 380
There is a weird GUI bug in tkinter on the interaction between the mouse pointer and a tkinter.Scrollbar
. The slider of the scrollbar is not at the location shown graphically and it doesn't move at the same speed as the mouse pointer sliding. It makes it very difficult to use. Here is a sample code, borrowed from http://effbot.org/tkinterbook/scrollbar.htm:
#!/usr/bin/env python3 # python 3.4.3 using ActiveTcl 8.5.18
#!/usr/bin/env python # python 2.7.10 using ActiveTcl 8.5.18
#!/usr/bin/python # os-x-native python 2.7.5 using os-x-native Tcl 8.5.9 [WORKS]
# Example from http://effbot.org/tkinterbook/scrollbar.htm
try:
# Python2
import Tkinter as tk
except ImportError:
# Python3
import tkinter as tk
import tkinter.ttk as ttk
import sys
master = tk.Tk()
# print version info:
sys.stdout.write("Python: %s.%s.%s\nTcl: %s\n" % (sys.version_info[0], sys.version_info[1], sys.version_info[2], tk.Tcl().eval("info patchlevel")))
# scrollbar = ttk.Scrollbar(master)
scrollbar = tk.Scrollbar(master)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
listbox = tk.Listbox(master, yscrollcommand=scrollbar.set)
for i in range(1000):
listbox.insert(tk.END, str(i))
listbox.pack(side=tk.LEFT, fill=tk.BOTH)
scrollbar.config(command=listbox.yview)
tk.mainloop()
Try to click-and-drag the slider: it doesn't work. If you click-and-drag below the slider, then it works. It looks like the mouse-reactive slider doesn't correspond to the visual slider. Also, the speed at which the slider moves when dragging doesn't correspond to the mouse speed...
This only occurs on mac using ActiveTcl 8.5.18 (the recommended version on mac for Python >= 2.7.10 including Python 3). Everything works fine when using the osx-native python 2.7.5 and osx-native Tcl 8.5.9 (os x 10.9.5).
The problem is absent on linux with python 3.4.3 and Tcl 8.6.1, not sure on windows.
Would anyone know a workaround/fix? Using the themed-widget version of Scrollbar doesn't resolve the problem.
Upvotes: 0
Views: 629
Reputation: 21
This is not a bug in tkinter, but a bug in the Mac implementation of Tk, starting with version 8.5.18 and 8.6.4. In these two versions the native scrollbar was removed because the Cocoa scrolling management had all kinds of hidden issues with Tk. The scrollbar is now drawn using HItheme, but this introduced the described offset between the visual slider and the area that acts like the slider. There is currently no fix for this. See here for more details:
https://sourceforge.net/p/tcl/mailman/tcl-mac/?viewmonth=201703
Upvotes: 0