Skip to content

Commit 3e7694b

Browse files
committed
Merge branch 'fix_#9'
Fix #9 by putting `after_cancel` in try/except block to catch the `ValueError` which is raised since Python 3.6.5 if there is nothing to cancel.
2 parents 02170d7 + bff1b65 commit 3e7694b

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ Documentation
115115
Changelog
116116
---------
117117

118+
- tkfilebrowser 2.2.2
119+
* Fix ValueError in after_cancel with Python 3.6.5
120+
118121
- tkfilebrowser 2.2.1
119122
* Fix __main__.py for python 2
120123

changelog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Copyright 2017 Juliette Monsel <j_4321@protonmail.com>
55

66
Changelog
77
---------
8+
9+
- tkfilebrowser 2.2.2
10+
* Fix ValueError in after_cancel with Python 3.6.5
11+
812
- tkfilebrowser 2.2.1
913
* Fix __main__.py for python 2
1014

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
long_description = f.read()
1313

1414
setup(name='tkfilebrowser',
15-
version='2.2.1',
15+
version='2.2.2',
1616
description='File browser for Tkinter, alternative to tkinter.filedialog in linux with GTK bookmarks support.',
1717
long_description=long_description,
1818
url='https://github.com/j4321/tkFileBrowser',

tkfilebrowser/tooltip.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ def __init__(self, tree, delay=1500, **kwargs):
101101
self.current_item = None
102102

103103
self.tree.bind('<Motion>', self._on_motion)
104-
self.tree.bind('<Leave>', lambda e: self.tree.after_cancel(self._timer_id))
104+
self.tree.bind('<Leave>', self._on_leave)
105+
106+
def _on_leave(self, event):
107+
try:
108+
self.tree.after_cancel(self._timer_id)
109+
except ValueError:
110+
# nothing to cancel
111+
pass
105112

106113
def add_tooltip(self, item, text):
107114
"""Add a tooltip with given text to the item."""
@@ -116,7 +123,11 @@ def _on_motion(self, event):
116123
self.tooltip.withdraw()
117124
self.current_item = None
118125
else:
119-
self.tree.after_cancel(self._timer_id)
126+
try:
127+
self.tree.after_cancel(self._timer_id)
128+
except ValueError:
129+
# nothing to cancel
130+
pass
120131
self._timer_id = self.tree.after(self.delay, self.display_tooltip)
121132

122133
def display_tooltip(self):

0 commit comments

Comments
 (0)