[core/decorators] use difflib to make scrolling reset detection fuzzy
when scrolling text that is subject to *slight* changes (e.g. a song that contains the current position within the song), allow for slight variations in the displayed text. fixes #629
This commit is contained in:
parent
0238d59f8b
commit
526560ea54
2 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
import difflib
|
||||
import util.format
|
||||
|
||||
|
||||
|
@ -28,7 +29,10 @@ def scrollable(func):
|
|||
if not text:
|
||||
return text
|
||||
|
||||
if text != widget.get("__content__", text):
|
||||
if (
|
||||
difflib.SequenceMatcher(a=text, b=widget.get("__content__", text)).ratio()
|
||||
< 0.9
|
||||
):
|
||||
widget.set("scrolling.start", 0)
|
||||
widget.set("scrolling.direction", "right")
|
||||
widget.set("__content__", text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue