-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
150 lines (127 loc) · 4.54 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
"""
Script for managing hot reloading of the project.
For more details see the documentation page -
https://kivymd.readthedocs.io/en/latest/api/kivymd/tools/patterns/create_project/
To run the application in hot boot mode, execute the command in the console:
DEBUG=1 python main.py
"""
import importlib
import os
# from kivy import Config
# from PIL import ImageGrab
# TODO: You may know an easier way to get the size of a computer display.
# resolution = ImageGrab.grab().size
# Change the values of the application window size as you need.
# Config.set("graphics", "height", resolution[1])
# Config.set("graphics", "width", "400")
from kivy.core.window import Window
from kivy.clock import Clock
# Place the application window on the right side of the computer screen.
# Window.top = 0
# Window.left = resolution[0] - Window.width
Window.size = (650, 650)
Window.softinput_mode = "below_target"
#
# from kivymd.tools.hotreload.app import MDApp
# from kivymd.uix.screenmanager import MDScreenManager
#
#
# class D2desk(MDApp):
# KV_DIRS = [os.path.join(os.getcwd(), "View")]
#
# def build_app(self) -> MDScreenManager:
# """
# In this method, you don't need to change anything other than the
# application theme.
# """
#
# import View.screens
#
# self.title = "D2Desk"
# self.manager_screens = MDScreenManager()
# Window.bind(on_key_down=self.on_keyboard_down)
# importlib.reload(View.screens)
# screens = View.screens.screens
#
# for i, name_screen in enumerate(screens.keys()):
# model = screens[name_screen]["model"]()
# 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)
#
# return self.manager_screens
#
# def goto_login(self, *args):
# self.manager_screens.current = "login screen"
#
# def on_start(self):
# print("Starting splash screen")
#
# Clock.schedule_once(self.goto_login, 2)
#
# def on_keyboard_down(self, window, keyboard, keycode, text, modifiers) -> None:
# """
# The method handles keyboard events.
#
# By default, a forced restart of an application is tied to the
# `CTRL+R` key on Windows OS and `COMMAND+R` on Mac OS.
# """
#
# if "meta" in modifiers or "ctrl" in modifiers and text == "r":
# self.rebuild()
#
#
# D2desk().run()
# After you finish the project, remove the above code and uncomment the below
# code to test the application normally without hot reloading.
# """
# 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/Model–view–controller
# """
#
from kivymd.app import MDApp
from kivymd.uix.screenmanager import MDScreenManager
#
from View.screens import screens
class D2desk(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.load_all_kv_files(self.directory)
# This is the screen manager that will contain all the screens of your
# application.
self.manager_screens = MDScreenManager()
def build(self) -> MDScreenManager:
self.title = "D2Desk"
self.generate_application_screens()
return self.manager_screens
def generate_application_screens(self) -> None:
"""
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"]()
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)
def goto_login(self, *args):
self.manager_screens.current = "login screen"
def on_start(self):
print("Starting splash screen")
Clock.schedule_once(self.goto_login, 2)
D2desk().run()