From 803bbb041149f9ca3ad2739c7023bc5522e71ffd Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 18 Jul 2018 13:35:25 +0200 Subject: [PATCH] Create boxes only when needed --- kivyforms/formcanvas.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/kivyforms/formcanvas.py b/kivyforms/formcanvas.py index 4cd1b80..0e233fb 100644 --- a/kivyforms/formcanvas.py +++ b/kivyforms/formcanvas.py @@ -70,20 +70,19 @@ class Grabbable(BoxLayout): widget.parent.add_widget(self, index=idx + 1) elif widget.point_area == 'bottom': widget.parent.add_widget(self, index=idx) - elif widget.point_area == 'left': - parent = widget.parent - box = parent.create_box() - parent.add_widget(box, index=idx) - box.add_widget(self) - parent.remove_widget(widget) - box.add_widget(widget) else: parent = widget.parent - box = parent.create_box() - parent.add_widget(box, index=idx) - parent.remove_widget(widget) - box.add_widget(widget) - box.add_widget(self) + if not isinstance(parent, BoxLayout): + box = parent.create_box() + parent.add_widget(box, index=idx) + parent.remove_widget(widget) + box.add_widget(widget) + idx = 0 + parent = box + if widget.point_area == 'left': + parent.add_widget(self, index=idx + 1) + else: + parent.add_widget(self, index=idx) widget.point() break else: -- 2.39.5