from kivy.app import App
from kivy.lang import Builder
from kivy.uix.textinput import TextInput
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import StringProperty
from kivy.properties import ObjectProperty
from kivy.uix.label import Label
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.boxlayout import BoxLayout
from kivy_garden.mapview import MapView
kv = '''
<Login>
ben: benName.text
pw: passwort.text
knopf: btn
knopff: btnn
GridLayout:
cols: 1
size: root.width,root.height
GridLayout:
cols: 2
Label:
text: "Username"
font_size: 25
TextInput:
id: benName
multiline: False
font_size: 30
Label:
text: "Password"
font_size: 25
bold: True
TextInput:
password: True
id: passwort
multiline: False
font_size: 40
Button:
size_hint: (1.,1.10)
text:" Start "
id: btn
font_size: 40
on_release:
root.manager.current = "Map" if passwort.text == "1" and benName.text == "1" else "login"
root.manager.transition.direction = "down"
Button:
size_hint: (1.,1.10)
text: " Exit "
id: btnn
font_size: 40
on_release: app.stop()
<Map>
BoxLayout:
Button:
text: " [back] "
bold: True
font_size: 17
size_hint: (None,None)
width: 100
height: 40
on_release: app.stop()
'''
MyApp
class:
class Login(Screen):
ben = StringProperty()
pw = StringProperty()
knopf = ObjectProperty()
class MyApp(App):
Builder.load_string(kv)
def build(self):
ms = ScreenManager()
ms.add_widget(Login(name='login'))
ms.add_widget(Map(name='Map'))
self.title = "MyApp"
return ms
class Map(Screen):
def build(self):
mapview = MapView(zoom=11, lat=50.6394, lon=3.057)
return mapview
if __name__ == '__main__':
MyApp().run()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…