-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainh.py
76 lines (57 loc) · 2.12 KB
/
mainh.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
"""
Script to manage hot-reload of the app.
"""
import os
import registers
import importlib
from kivy import Config
from PIL import ImageGrab
resolution = ImageGrab.grab().size
# Change the values of the application window size as you need.
Config.set("graphics", "height", "690")
Config.set("graphics", "width", "317")
from kivy.core.window import Window
# Place the application window on the right side of the computer screen.
Window.top = 30
Window.left = resolution[0] - Window.width + 5
import webbrowser
from kivymd.tools.hotreload.app import MDApp
from kivymd.uix.screenmanager import MDScreenManager
from kivymd.uix.transition import MDSharedAxisTransition as SAT
class UI(MDScreenManager):
def __init__(self, *args, **kwargs):
super(UI, self).__init__(*args, **kwargs)
self.transition = SAT()
class KvDeveloper(MDApp):
def __init__(self, *args, **kwargs):
super(KvDeveloper, self).__init__(*args, **kwargs)
self.DEBUG = True
self.KV_DIRS = [
os.path.join(os.getcwd(), "View"),
]
self.theme_cls.primary_palette = "Midnightblue"
def build_app(self) -> UI:
self.manager_screens = UI()
self.generate_application_screens()
return self.manager_screens
def generate_application_screens(self) -> None:
"""
Adds different screen widgets to the screen manager
"""
import View.screens
importlib.reload(View.screens)
screens = View.screens.screens
for i, name_screen in enumerate(screens.keys()):
view = screens[name_screen]["object"]()
view.manager_screens = self.manager_screens
view.name = name_screen
self.manager_screens.add_widget(view)
def apply_styles(self, style: str = "Light") -> None:
self.theme_cls.theme_style = style
def referrer(self, destination: str = None) -> None:
if self.manager_screens.current != destination:
self.manager_screens.current = destination
def web_open(self, url: str) -> None:
webbrowser.open_new_tab(url)
if __name__ == "__main__":
KvDeveloper().run()