#main.py
from kivy.lang import Builder
从 kivymd.app 导入 MDApp
类 MainApp(MDApp):
def build(self):
self.theme_cls.theme_style = 'Dark'
self.theme_cls.primary_palette = 'BlueGray'
return Builder.load_file('main.kv')
MainApp().run()
#main.kv
#: 导入地图视图 kivy.garden.mapview.MapView
MDBoxLayout:方向:'垂直'
MDBoxLayout:
size_hint: (1, .1)
Label:
text: 'how to print the on_lat and on_lon on the label below (its now print on terminal)'
MDBoxLayout:
size_hint: (1, .8)
MapView:
lat: 5.66774
lon: 116.36641
zoom: 12
on_lat:
print('lat', self.lat)
on_lon:
print('lon', self.lon)
MDBoxLayout:
size_hint: (1, .1)
Label:
id: latlon
text: 'print (on_lat) and (on_lon) here'