Sideband_CE/sbapp/kivymd/tools/patterns/MVC/main.py_tmp
2022-07-07 22:16:10 +02:00

55 lines
1.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
The entry point to the application.
The application uses the MVC template. Adhering to the principles of clean
architecture means ensuring that your application is easy to test, maintain,
and modernize.
You can read more about this template at the links below:
https://github.com/HeaTTheatR/LoginAppMVC
https://en.wikipedia.org/wiki/Modelviewcontroller
"""
from typing import NoReturn
from kivy.uix.screenmanager import ScreenManager%s
from kivymd.app import MDApp
from View.screens import screens%s
%s
class %s(MDApp):%s
def __init__(self, **kwargs):
super().__init__(**kwargs)%s
self.load_all_kv_files(self.directory)
# This is the screen manager that will contain all the screens of your
# application.
self.manager_screens = ScreenManager()
%s
def build(self) -> ScreenManager:
self.generate_application_screens()
return self.manager_screens
def generate_application_screens(self) -> NoReturn:
"""
Creating and adding screens to the screen manager.
You should not change this cycle unnecessarily. He is self-sufficient.
If you need to add any screen, open the `View.screens.py` module and
see how new screens are added according to the given application
architecture.
"""
for i, name_screen in enumerate(screens.keys()):
model = screens[name_screen]["model"](%s)
controller = screens[name_screen]["controller"](model)
view = controller.get_view()
view.manager_screens = self.manager_screens
view.name = name_screen
self.manager_screens.add_widget(view)
%s%s
%s().run()