From 63c9141d0b1b53e6c63a93f86e814533abbd1b89 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 23 Jul 2021 10:05:34 +0800 Subject: [PATCH] bugfix --- kivyblocks/twosides.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kivyblocks/twosides.py b/kivyblocks/twosides.py index 4bd1964..1363020 100644 --- a/kivyblocks/twosides.py +++ b/kivyblocks/twosides.py @@ -109,9 +109,10 @@ class TwoSides(WidgetReady, BoxLayout): self.dispatch('on_beforeswitch_landscape') self.clear_widgets() self.add_widget(self.landscape_widget) - if self.switch_button_showed: + if self.switch_button_showed and self.cannt_rotation: self.set_switch_button_pos() - Window.add_widget(self.switch_button) + if self.switch_button not in Window.children: + Window.add_widget(self.switch_button) self.dispatch('on_afterswitch_landscape') self.panel_shape = 'landscape' else: @@ -119,14 +120,14 @@ class TwoSides(WidgetReady, BoxLayout): self.app.get_rotation(), Window.size) if not self.portrait_widget in self.children: - self.dispatch('on_beforeswitch_landscape') + self.dispatch('on_beforeswitch_portrait') self.clear_widgets() self.add_widget(self.portrait_widget) - if self.switch_button_showed: + if self.switch_button in Window.children: Window.remove_widget(self.switch_button) self.cannt_rotation = False self.panel_shape = 'portrait' - self.dispatch('on_afterswitch_landscape') + self.dispatch('on_afterswitch_portrait') self.dispatch('on_interactive') def on_beforeswitch_landscape(self, *args):