diff --git a/examples/android/compass/main.py b/examples/android/compass/main.py index 4e7818ee23..1fea872609 100644 --- a/examples/android/compass/main.py +++ b/examples/android/compass/main.py @@ -65,4 +65,3 @@ def on_resume(self): if __name__ == '__main__': CompassApp().run() - diff --git a/examples/container/kv/1.kv b/examples/container/kv/1.kv index 10c5d7b770..19634ebc91 100644 --- a/examples/container/kv/1.kv +++ b/examples/container/kv/1.kv @@ -2,29 +2,27 @@ #:import datetime datetime RootWidget: - - # import container + # import container container: container - # fill the container + # fill the container BoxLayout: id: container - orientation: 'vertical' - padding: 0 - spacing: 3 + orientation: 'vertical' + padding: 0 + spacing: 3 - Label: + Label: text: 'screen-1' - BoxLayout: orientation: 'horizontal' padding: 0 spacing: 1 - size_hint: 1,0.1 + size_hint: 1, 0.1 # weiter button Button: - size_hint: 0.2,1 + size_hint: 0.2, 1 text: 'next' on_release: app.next_screen('2') diff --git a/examples/container/kv/2.kv b/examples/container/kv/2.kv index 7a8a00c559..4a88ee7733 100644 --- a/examples/container/kv/2.kv +++ b/examples/container/kv/2.kv @@ -2,29 +2,27 @@ #:import datetime datetime RootWidget: - - # import container + # import container container: container - # fill the container + # fill the container BoxLayout: id: container - orientation: 'vertical' - padding: 0 - spacing: 3 + orientation: 'vertical' + padding: 0 + spacing: 3 - Label: + Label: text: 'screen-2' - BoxLayout: orientation: 'horizontal' padding: 0 spacing: 1 - size_hint: 1,0.1 + size_hint: 1, 0.1 # weiter button Button: - size_hint: 0.2,1 + size_hint: 0.2, 1 text: 'next' on_release: app.next_screen('3') diff --git a/examples/container/kv/3.kv b/examples/container/kv/3.kv index fa7138dad4..c4a7a2e907 100644 --- a/examples/container/kv/3.kv +++ b/examples/container/kv/3.kv @@ -2,29 +2,27 @@ #:import datetime datetime RootWidget: - - # import container + # import container container: container - # fill the container + # fill the container BoxLayout: id: container - orientation: 'vertical' - padding: 0 - spacing: 3 + orientation: 'vertical' + padding: 0 + spacing: 3 - Label: + Label: text: 'screen-3' - BoxLayout: orientation: 'horizontal' padding: 0 spacing: 1 - size_hint: 1,0.1 + size_hint: 1, 0.1 # weiter button Button: - size_hint: 0.2,1 + size_hint: 0.2, 1 text: 'next' on_release: app.next_screen('1') diff --git a/examples/container/kv/root.kv b/examples/container/kv/root.kv index d538f43949..b927522d6f 100644 --- a/examples/container/kv/root.kv +++ b/examples/container/kv/root.kv @@ -1,32 +1,32 @@ #:kivy 1.8.0 RootWidget: - # import container - container: container + # import container + container: container - BoxLayout: - orientation: 'vertical' - padding: 0 - spacing: 6 + BoxLayout: + orientation: 'vertical' + padding: 0 + spacing: 6 - # bottom-left part: - BoxLayout: - orientation: 'horizontal' - padding: 0 - spacing: 6 + # bottom-left part: + BoxLayout: + orientation: 'horizontal' + padding: 0 + spacing: 6 - # bottom-left - BoxLayout: - size_hint: 0.12, 0.12 - orientation: 'vertical' - padding: 0 - spacing: 6 + # bottom-left + BoxLayout: + size_hint: 0.12, 0.12 + orientation: 'vertical' + padding: 0 + spacing: 6 - # option calibrate - Button: - text: 'Start' - on_release: app.next_screen('1') + # option calibrate + Button: + text: 'Start' + on_release: app.next_screen('1') - # create container (bottom-right) - BoxLayout: - id: container + # create container (bottom-right) + BoxLayout: + id: container diff --git a/examples/container/main.py b/examples/container/main.py index 856ea3bf93..194a4b4a74 100644 --- a/examples/container/main.py +++ b/examples/container/main.py @@ -28,9 +28,6 @@ class RootWidget(BoxLayout): class EzsApp(App): '''This is the app itself''' - # setting the path of our directory - path = os.path.abspath(os.path.dirname(".")) - error = False def build(self): '''This method loads the root.kv file automatically @@ -38,9 +35,7 @@ def build(self): :rtype: none ''' # loading the content of root.kv - self.root = Builder.load_file(os.path.join(self.path, 'kv', 'root.kv')) - - return self.root + self.root = Builder.load_file('kv/root.kv') def next_screen(self, screen): '''Clear container and load the given screen object from file in kv @@ -53,20 +48,17 @@ def next_screen(self, screen): filename = screen + '.kv' # unload the content of the .kv file - # reason: it could have data form previous calls - setattr(self, screen, Builder.unload_file( - os.path.join(self.path, 'kv', filename))) - # load the content of the .kv file - setattr(self, screen, Builder.load_file( - os.path.join(self.path, 'kv', filename))) + # reason: it could have data from previous calls + Builder.unload_file('kv/' + filename) # clear the container self.root.container.clear_widgets() + # load the content of the .kv file + screen = Builder.load_file('kv/' + filename) # add the content of the .kv file to the container - self.root.container.add_widget(getattr(self, screen)) + self.root.container.add_widget(screen) if __name__ == '__main__': '''Start the application''' - EZS = EzsApp() - EZS.run() + EzsApp().run()