Title: Tkinter scroll issues on macOS
Type: behavior Stage:
Components: Tkinter Versions: Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: serhiy.storchaka, vtudorache, wordtech
Priority: normal Keywords:

Created on 2018-08-10 10:07 by vtudorache, last changed 2018-08-15 08:42 by vtudorache.

File name Uploaded Description Edit vtudorache, 2018-08-10 18:28 vtudorache, 2018-08-10 18:34
Messages (5)
msg323363 - (view) Author: Vlad Tudorache (vtudorache) * Date: 2018-08-10 10:07
Run the python script below.

import tkinter

root = tkinter.Tk()

text = tkinter.Text(root)
vbar = tkinter.Scrollbar(root)

vbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
text.pack(side=tkinter.LEFT, fill=tkinter.BOTH, expand=1)


lines = ['This is the line number %d.\n' % i for i in range(256)]
text.insert(tkinter.END, ''.join(lines))
def click_trace(event):
    text.insert('%d.%d' % (1, 0), 'Clicked at (%d,%d) on %s.\n' % (event.x, event.y, vbar.identify(event.x, event.y)))

vbar.bind('<Button-1>', click_trace)


When the slider is at the top of the scrollbar, clicking on its upper half doesn't allow dragging. The little script shows that the Scrollbar considers it as being on "through1" - in Tk the zone between the upper arrow and the "slider" - and not on "slider". Another consequence is that one can drag (up and down) the slider when clicking a little bit below the slider, on "through2" region. This issue doesn't manifest on Windows, where the scrollbar's arrows are shown.
I've seen this issue when trying to explore the reasons of another (34047, fixed) concerning the slider locked at the end of the scrollbar in IDLE.
msg323379 - (view) Author: Vlad Tudorache (vtudorache) * Date: 2018-08-10 18:28
The bug needs forwarding to the Tcl/Tk community. This is the script written in Tcl (run with tclsh8.6 script.tcl for Tcl 8.6 and tclsh8.5 script.tcl for 8.5):

package require Tk

scrollbar .vbar -width 10
text .edit

pack .vbar -side right -fill y
pack .edit -side left -fill both -expand 1

.vbar configure -command {.edit yview}
.edit configure -yscrollcommand {.vbar set}

bind .vbar {<Button-1> } {
	set cx %x
	set cy %y
	set dz [.vbar identify $cx $cy]
	puts "You clicked at ($cx,$cy) on $dz.\n"

for {set i 1} {$i <= 256} {incr i} {
	.edit insert "$i.0" "This is the line number $i.\n"

I will post two videos made on my MacBook, showing an expected behavior with Tk 8.5 and the scroll problems with Tk 8.6 on macOS.
msg323381 - (view) Author: Vlad Tudorache (vtudorache) * Date: 2018-08-10 18:34
Now, the video for TK 8.5 showing expected behavior on macOS.
msg323547 - (view) Author: Kevin Walzer (wordtech) * Date: 2018-08-15 02:40
I just committed, which fixes the scrolling issue in Tk. Running the test scripts here indicate the behavior is now correct; clicking several pixels below the bottom part of the scroll button causes the scroll to jump, instead of smoothly scrolling. (One must click the scroll button directly for smooth scrolling, which is the expected behavior.) The fix involved removing support for a small scroll button variant, which was causing the confusion; by sticking with a single variant, the normal size scroller, the behavior is correct and consistent.
msg323558 - (view) Author: Vlad Tudorache (vtudorache) * Date: 2018-08-15 08:42
It seems that Kevin's fix solves the issues.
Date User Action Args
2018-08-15 08:42:32vtudorachesetmessages: + msg323558
2018-08-15 02:40:53wordtechsetmessages: + msg323547
2018-08-12 23:10:00terry.reedysetnosy: + wordtech, serhiy.storchaka
2018-08-10 18:34:08vtudorachesetfiles: +

messages: + msg323381
2018-08-10 18:28:28vtudorachesetfiles: +

messages: + msg323379
2018-08-10 10:07:16vtudorachecreate