Replace type with isinstance
authorJavier Sancho <jsf@jsancho.org>
Wed, 18 Jul 2018 11:22:53 +0000 (13:22 +0200)
committerJavier Sancho <jsf@jsancho.org>
Wed, 18 Jul 2018 11:22:53 +0000 (13:22 +0200)
kivyforms/formcanvas.py

index 0f8f2fe..4cd1b80 100644 (file)
@@ -64,7 +64,7 @@ class Grabbable(BoxLayout):
         self.size_hint = self.form_canvas.widgets_size_hint
 
         for widget in self.form_canvas.walk(restrict=True):
-            if type(widget) is Grabbable and widget.collide_point(x, y):
+            if isinstance(widget, Grabbable) and widget.collide_point(x, y):
                 idx = widget.get_index()
                 if widget.point_area == 'top':
                     widget.parent.add_widget(self, index=idx + 1)
@@ -158,10 +158,10 @@ class FormCanvas(ButtonBehavior, StackLayout):
         widgets = self.walk(restrict=True)
         next(widgets)    # the first widget is the FormCanvas
         for widget in widgets:
-            if not type(widget) is Grabbable:
+            if not isinstance(widget, Grabbable):
                 # Look for the widget position inside the tree
                 parent = widget.parent
-                if type(parent) is Grabbable:
+                if isinstance(parent, Grabbable):
                     parent = parent.parent
                 while not parent is stack[-1]:
                     stack.pop()