From 0cb1d6f60dfdf05fba0769d95591318dc306dbf5 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 17 Jan 2021 19:21:51 +0800 Subject: [PATCH] bugfix --- kivyblocks/orientationlayout.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kivyblocks/orientationlayout.py b/kivyblocks/orientationlayout.py index ffff6e4..164f49c 100644 --- a/kivyblocks/orientationlayout.py +++ b/kivyblocks/orientationlayout.py @@ -25,6 +25,8 @@ class OrientationLayout(WidgetReady, SwipeBehavior, FloatLayout): self.bind(on_swipe_right=self.toggle_second) self.bind(size=self.on_size_changed) self.bind(pos=self.on_size_changed) + self.current_orient = None + self.register_event_type('on_orientation_changed') def build_children(self, *args): if isinstance(self.main_widget, dict): @@ -52,8 +54,19 @@ class OrientationLayout(WidgetReady, SwipeBehavior, FloatLayout): self.on_size_changed(self.size) def on_size_changed(self,*args): + old_orient = self.current_orient + if self.isLandscape(): + self.current_orient = 'landscape' + else: + self.current_orient = 'portrait' + if old_orient and old_orient != self.current_orient: + self.dispatch('on_orientation_changed') + Clock.schedule_once(self.two_widget_layout,0) + def on_orientation_changed(self, *args): + print('on_orientation_changed fired') + def two_widget_layout(self, *args): if not isinstance(self.widget_main, Widget) or not isinstance(self.widget_second, Widget): # Clock.schedule_once(self.two_widget_layout,0)