-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
109 lines (89 loc) · 3.32 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
from kivymd.app import MDApp
import kivy
from kivy.lang import Builder
from kivy.animation import Animation
from kivy.utils import platform
import platform as pl
from kivy.core.text import LabelBase
from kivy.core.window import Window
from kivy.clock import Clock
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.screenmanager import (
NoTransition,
SlideTransition,
CardTransition,
SwapTransition,
FadeTransition,
WipeTransition,
FallOutTransition,
RiseInTransition
)
import sys
from kivy.core.window import Window
from kivy.core.clipboard import Clipboard
# mine Screens
from screens.levels.levels import LevelsScreen
from screens.table.table import TableScreen
from screens.finish.finish import FinishScreen
from screens.faq.faq import FaqScreen
__version__ = '1.3'
if platform != 'android':
Window.size = (350, 750)
Window.top = 70
Window.right = 70
class MenuScreen(Screen):
#from jnius import autoclass
def share(self):
title = 'Title'
appgallery = 'https://appgallery.huawei.com/app/C107717287'
google_play = 'https://play.google.com/store/apps/details?id=org.irregular_verbs.irregular_verbs'
text = f"AppGallery: {appgallery} \n\n Google Play: {google_play}"
if platform == 'android':
from jnius import autoclass
PythonActivity = autoclass('org.kivy.android.PythonActivity')
Intent = autoclass('android.content.Intent')
String = autoclass('java.lang.String')
intent = Intent()
intent.setAction(Intent.ACTION_SEND)
intent.putExtra(Intent.EXTRA_TEXT, String('{}'.format(text)))
intent.setType('text/plain')
chooser = Intent.createChooser(intent, String(title))
PythonActivity.mActivity.startActivity(chooser)
else:
Clipboard.copy(text)
def close_app(self):
sys.exit()
class MainApp(MDApp):
app_version = __version__
def on_key(self, window, key, *args):
if key == 27: # the esc key
if self.sm.current == 'menu_screen':
return False
else:
self.sm.transition = FadeTransition(duration=.1)
self.sm.current = "menu_screen"
return True
def build(self):
Builder.load_file('main.kv')
Builder.load_file('screens/table/table.kv')
Builder.load_file('screens/levels/levels.kv')
Builder.load_file('screens/faq/faq.kv')
self.theme_cls.theme_style = "Light"
self.theme_cls.primary_palette = "Green"
Window.bind(on_keyboard=self.on_key)
self.sm = ScreenManager()
self.sm = ScreenManager(transition=FadeTransition(duration=.1))
# Create some screens
self.sm.add_widget(MenuScreen(name='menu_screen'))
self.sm.add_widget(LevelsScreen(name='levels_screen'))
self.sm.add_widget(TableScreen(name='table_screen'))
self.sm.add_widget(FaqScreen(name='faq_screen'))
return self.sm
if __name__ == '__main__':
LabelBase.register(name='OpenSans',
fn_regular='fonts/OpenSans/OpenSans-Regular.ttf',
fn_italic='fonts/OpenSans/OpenSans-Italic.ttf',
fn_bold='fonts/OpenSans/OpenSans-Bold.ttf',
fn_bolditalic='fonts/OpenSans/OpenSans-BoldItalic.ttf',
)
MainApp().run()