From 49f5bab67fd68908006ae5fdeb4c0ce6f23b3969 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Tue, 9 Nov 2010 19:29:01 +0100 Subject: [PATCH 1/3] widget: allow parent to be None (in case of remove_widget for eg) --- kivy/uix/widget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kivy/uix/widget.py b/kivy/uix/widget.py index 76165657e..243f84c1d 100644 --- a/kivy/uix/widget.py +++ b/kivy/uix/widget.py @@ -336,7 +336,7 @@ class Widget(EventDispatcher): children = ListProperty([]) #: Parent - parent = ObjectProperty(None) + parent = ObjectProperty(None, allownone=True) #: Size hint X size_hint_x = NumericProperty(1, allownone=True) From edd69d63ffe16d33dea5ea49d1d92a282e0cdc16 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Tue, 9 Nov 2010 19:29:15 +0100 Subject: [PATCH 2/3] graphics: make canvas recompile when a child is added/removed --- kivy/c_ext/graphics.pyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kivy/c_ext/graphics.pyx b/kivy/c_ext/graphics.pyx index 78eb8f87a..a0ba99be7 100644 --- a/kivy/c_ext/graphics.pyx +++ b/kivy/c_ext/graphics.pyx @@ -91,10 +91,12 @@ cdef class Canvas: cpdef add_canvas(self, Canvas canvas): if not canvas in self._children: self._children.append(canvas) + self._need_compile = 1 cpdef remove_canvas(self, Canvas canvas): if canvas in self._children: self._children.remove(canvas) + self._need_compile = 1 cdef add(self, GraphicInstruction instruction): self.need_compile = 1 From 3e0443a2d3817e106d2b6ef6e9076801d20ccf6d Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Tue, 9 Nov 2010 19:29:26 +0100 Subject: [PATCH 3/3] kvrun: press F5 to reload app --- examples/kv/kvrun.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/kv/kvrun.py b/examples/kv/kvrun.py index b03b40545..e690151bc 100644 --- a/examples/kv/kvrun.py +++ b/examples/kv/kvrun.py @@ -3,13 +3,24 @@ from kivy.app import App from kivy.clock import Clock from kivy.lang import Builder +from kivy.core.window import Window class KvApp(App): def _print_fps(self, *largs): print 'FPS: %2.4f (real draw: %d)' % ( Clock.get_fps(), Clock.get_rfps()) + + def _reload_keypress(self, instance, code, *largs): + if code != 286: + return + for child in Window.children[:]: + Window.remove_widget(child) + root = Builder.load_file(self.options['filename']) + Window.add_widget(root) + def build(self): Clock.schedule_interval(self._print_fps, 1) + Window.bind(on_keyboard=self._reload_keypress) return Builder.load_file(self.options['filename']) if __name__ == '__main__':