two screens, one of them with a map that has a centered marker on it

This commit is contained in:
rgarcia-herrera 2020-07-16 11:25:49 -05:00
parent 318d1ae9b7
commit e0af3de69c
2 changed files with 74 additions and 0 deletions

33
flockompass.kv Normal file
View File

@ -0,0 +1,33 @@
#:import random random.random
#:import RiseInTransition kivy.uix.screenmanager.RiseInTransition
<MapScreen>:
BoxLayout:
Button:
text: 'Goto settings'
on_press: root.manager.current = 'compass'
MapView:
id: mapview
lat: 28.89335172
lon: 76.59449171
zoom: 15
on_map_relocated: centermark.lat = mapview.lat; centermark.lon = mapview.lon
MapMarker:
id: centermark
anchor_x: 0.2
anchor_y: 0.3
lat: 28.89335172
lon: 76.59449171
<CompassScreen>:
BoxLayout:
Button:
text: 'My settings button'
Button:
text: 'Back to menu'
on_press: root.manager.current = 'map'

41
main.py Normal file
View File

@ -0,0 +1,41 @@
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen, RiseInTransition
from kivy.properties import NumericProperty
from kivy.lang import Builder
from kivy_garden.mapview import MapView
class MapScreen(Screen):
hue = NumericProperty(0)
mapview = MapView(zoom=11, lat=50.6394, lon=3.057)
class CompassScreen(Screen):
hue = NumericProperty(0)
class FlockompassApp(App):
def build(self):
root = ScreenManager(transition=RiseInTransition())
root.add_widget(MapScreen(name='map'))
root.add_widget(CompassScreen(name='compass'))
return root
if __name__ == '__main__':
FlockompassApp().run()
# Button:
# text: 'Use FallOutTransition'
# on_release: root.manager.transition = FallOutTransition()
# Button:
# text: 'Use RiseInTransition'
# on_release: root.manager.transition = RiseInTransition()