一、版本介绍
Ubuntu:18.04.6 LTS
Conda:4.5.12
Python:3.6.15
Kivy:2.0.0
二、安装Kivy
bash
# 更新系统包列表
sudo apt-get update
# 安装Kivy的依赖项
sudo apt-get install -y python-pip libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev zlib1g-dev
python -m pip install docutils pygments pypiwin32
pip install pygame -i https://pypi.tuna.tsinghua.edu.cn/simple
sudo apt-get install xclip
# 安装Cython(可选,但推荐以加速Kivy的安装)
sudo apt-get install -y cython3
sudo apt-get install -y cython
# 视频摄像头相关
python -m pip install kivy.deps.gstreamer
# 安装Kivy
pip install kivy -i https://pypi.tuna.tsinghua.edu.cn/simple
# 如果你遇到任何关于OpenGL的问题,可能需要安装pre-releases版本的Kivy
pip install --pre kivy


python
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
class TestApp(App):
def build(self):
layout = BoxLayout(orientation="vertical")
title_bar = BoxLayout()
title_bar.add_widget(Button(text="btn1"))
title_bar.add_widget(Button(text="btn2"))
layout.add_widget(title_bar)
layout.add_widget(TextInput(text="Hllo"))
return layout
if __name__ == "__main__":
TestApp().run()


三、使用Kivy
官网篇:Kivy framework --- Kivy 2.3.0 documentation