Kivy Mapview - Place Button Widgets Ontop Of Mapview Widget
I'm trying to add some widgets to a Kivy mapview like this mapview = self.mapWidget(self.lat, self.lon) touchBarbtn1 = Button(text='Unlock') touchBarbtn1.bind(on_press=lamb
Solution 1:
- Use Kivy Anchor Layout.
- If you are going to add more buttons, my suggestion is to use Kivy Drop-Down List.
Example
main.py
from kivy.garden.mapview import MapView
from kivy.app import App
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.button import Button
from kivy.properties import NumericProperty
class RootWidget(AnchorLayout):
lat = NumericProperty(50.6394)
lon = NumericProperty(3.057)
def __init__(self, **kwargs):
super(RootWidget, self).__init__(**kwargs)
self.anchor_x = 'right'
self.anchor_y = 'top'
mapview = MapView(zoom=11, lat=self.lat, lon=self.lon)
self.add_widget(mapview)
touchBarbtn1 = Button(text='Unlock', size_hint=(0.1, 0.1))
touchBarbtn1.bind(on_press=lambda x: self.centerOnUser())
self.add_widget(touchBarbtn1)
def centerOnUser(self):
pass
class MapViewApp(App):
def build(self):
return RootWidget()
MapViewApp().run()
Post a Comment for "Kivy Mapview - Place Button Widgets Ontop Of Mapview Widget"