summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter/dnd.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-12-25 15:04:26 (GMT)
committerGitHub <noreply@github.com>2020-12-25 15:04:26 (GMT)
commitbb70b2afe39ad4334a9f3449cddd28149bd628b6 (patch)
tree6d86d962cf07b543fa5d25078a24bd4b9cee54ed /Lib/tkinter/dnd.py
parent954a7427ba9c2d02faed32c02090caeca873aeca (diff)
downloadcpython-bb70b2afe39ad4334a9f3449cddd28149bd628b6.zip
cpython-bb70b2afe39ad4334a9f3449cddd28149bd628b6.tar.gz
cpython-bb70b2afe39ad4334a9f3449cddd28149bd628b6.tar.bz2
bpo-15303: Support widgets with boolean value False in Tkinter (GH-23904)
Use `widget is None` instead of checking the boolean value of a widget.
Diffstat (limited to 'Lib/tkinter/dnd.py')
-rw-r--r--Lib/tkinter/dnd.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/Lib/tkinter/dnd.py b/Lib/tkinter/dnd.py
index 3120ff3..acec61b 100644
--- a/Lib/tkinter/dnd.py
+++ b/Lib/tkinter/dnd.py
@@ -108,7 +108,7 @@ __all__ = ["dnd_start", "DndHandler"]
def dnd_start(source, event):
h = DndHandler(source, event)
- if h.root:
+ if h.root is not None:
return h
else:
return None
@@ -143,7 +143,7 @@ class DndHandler:
def __del__(self):
root = self.root
self.root = None
- if root:
+ if root is not None:
try:
del root.__dnd
except AttributeError:
@@ -154,25 +154,25 @@ class DndHandler:
target_widget = self.initial_widget.winfo_containing(x, y)
source = self.source
new_target = None
- while target_widget:
+ while target_widget is not None:
try:
attr = target_widget.dnd_accept
except AttributeError:
pass
else:
new_target = attr(source, event)
- if new_target:
+ if new_target is not None:
break
target_widget = target_widget.master
old_target = self.target
if old_target is new_target:
- if old_target:
+ if old_target is not None:
old_target.dnd_motion(source, event)
else:
- if old_target:
+ if old_target is not None:
self.target = None
old_target.dnd_leave(source, event)
- if new_target:
+ if new_target is not None:
new_target.dnd_enter(source, event)
self.target = new_target
@@ -193,7 +193,7 @@ class DndHandler:
self.initial_widget.unbind("<Motion>")
widget['cursor'] = self.save_cursor
self.target = self.source = self.initial_widget = self.root = None
- if target:
+ if target is not None:
if commit:
target.dnd_commit(source, event)
else:
@@ -215,9 +215,9 @@ class Icon:
if canvas is self.canvas:
self.canvas.coords(self.id, x, y)
return
- if self.canvas:
+ if self.canvas is not None:
self.detach()
- if not canvas:
+ if canvas is None:
return
label = tkinter.Label(canvas, text=self.name,
borderwidth=2, relief="raised")
@@ -229,7 +229,7 @@ class Icon:
def detach(self):
canvas = self.canvas
- if not canvas:
+ if canvas is None:
return
id = self.id
label = self.label