python - 在与 kivy python 相同的窗口中添加 MapView 和按钮、标签等
问题描述
我从来没有使用过 OOP 和 Kivy,所以我在这里问你。我想在同一个屏幕中插入地图和按钮、标签等,但我真的不知道如何,你有任何教程或任何东西?
我当前的代码:
主要.py:
import kivy
from kivy.app import App
from kivy_garden.mapview import MapView
from kivy.uix.floatlayout import FloatLayout
class MyApp(App):
def build(self):
return FloatLayout()
if __name__ == "__main__":
MyApp().run()
我的.kv:
#:import MapView kivy.garden.mapview.MapView
MapView:
size_hint: 0.6,0.7
pos_hint: {"x":0.4, "top":0.8}
lat: 46.691858
lon: 3.048459
zoom: 6
on_lat:
print("latitude : ",self.lat)
on_lon:
print("longitude : ",self.lon)
MapMarkerPopup:
lat:46
lon:3
<Button>:
font_size: 24
color:0.5,0.2,0.3,1
size_hint: 0.1,0.05
<FloatLayout>:
Button:
pos_hint: {"x":0.02, "top":1}
text: "OK"
Button:
id: btn
text: "OK 2" if btn.state == "normal" else "Appui"
pos_hint: {"x":0.02, "top":0.9}
我认为这真的很简单,但目前我不知道该怎么做..
谢谢 !
PS:我为 windows 10、7 和 xp 开发此应用程序,而不是为 android
解决方案
推荐阅读
- regex - 使用正则表达式查询逗号分隔的数据
- qt - 即使使用 Qt 维护重新安装后也无法导入 QtCharts
- excel - 处理列表对象时对属性的无效使用
- python - 我在 Django 中上传 CSV 有什么问题?
- python - 在 python 中获取 FFT 波形以匹配 Adobe Audition 频率分析
- excel - 如何使用按钮隐藏/取消隐藏列?
- java - 使用布尔错误检查方法写入 LinkedList 会在另一个参数为整数的函数中显示错误
- javascript - 有没有办法为 JS(任何环境)创建转储并稍后恢复/调试它(可能在其他机器上)?
- django - 我应该在哪里设置从表单字段派生的模型字段?
- javascript - 如何使用自定义对象作为 TypeScript 地图中的键?