New submission from Tama-kun <[email protected]>:
This issue occurs when using the current mouse position from an event and the
wordstart expression to find the index of the start of a clicked word on a text
widget and the indices for the clicked word are tagged. If there's a single
non-alphanumberic and underline character between the clicked word and the left
edge of the text widget the index return for the start of the word will be the
one for said non-alphanumeric and underline character.
test.index(('@%s,%s wordstart' % (event.x, event.y)))
Assuming "[testing]" is at the indices 1.0 to 1.9 of a text widget, clicking on
testing will return 1.1. If we tag the indices 1.1 to 1.8 with
test.tag_add("tag", 1.1, 1.8) then clicking on the word testing will return
1.0. This change of return doesn't occur if "[testing]" does not begin at a x.0
index or if there's multiple non-alphanumeric and underline characters such as
"[[testing]". Using wordend will return 1.8 in both tagged and non tagged
scenarios.
The attached script illustrates this bug, only the middle text widget will
print out the unexpected start index when clicking on the word testing. This
issue isn't present when using python 3.5, running the script on python 3.5
will print out all expected indices.
----------
components: Tkinter
files: test.py
messages: 377716
nosy: Tama-kun, gpolo, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Moving index with wordstart expression includes non-alphanumberic and
underline characters if word is tagged and iat the edge of a text widget
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file49479/test.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41896>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com