---
title: "Python Kivy GUI Framework"
aliases:
date: 2022-02-22 08:46:00
tags: Säule/Technik Typ/Notiz
---
⬅️ **[[$-Tools|Tools]]**
***
# Python Kivy GUI Framework
- [Python GUI mit KIVY - Erste Schritte mit Fenstern und grafischen Oberflächen!](https://www.youtube.com/watch?v=6XoNpA_oYdw)
- [YouTube Playlist - Codemy - Python GUIs with Kivy](https://www.youtube.com/watch?v=dLgquj0c5_U&list=PLCC34OHNcOtpz7PJQ7Tv7hqFBP_xDDjqg)
## HelloWorld example
```python
import kivy
kivy.require('2.0.0')
from kivy.app import App
from kivy.uix.button import Label
class HelloKivy(App):
def build(self):
return Label(text="Hello Kivy World")
helloKivy = HelloKivy()
helloKivy.run()
```
## 02 Python und Kivy installieren in Windows
python -m pip install --upgrade pip setuptools virtualenv
source .\kivy_venv\Scripts\activate.bat
=> ERROR Ausführung von Skripts ist nicht erlaubt
=> Lösung: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned` in [[Windows PowerShell]] als Administrator eingeben und freigeben
source .\kivy_venv\Scripts\activate.bat
python -m pip install kivy[full] kivy_examples
## 01 Python und Kivy installieren in WSL2 in Windows -> Fehler
### Installation Python
sudo apt-get update
sudo apt-get upgrade
sudo apt install python3
sudo apt install python3-pip
### Installation Kivy + Project
python3 -m pip install --upgrade pip wheel setuptools
cd /KivyProject
python3 -m virtualenv kivy_venv
source kivy_venv/Scripts/activate
python3 -m pip install kivy[full] kivy_examples
### HelloWorld - with all WSL2 fixes
```python
import kivy
kivy.require('2.0.0')
from kivy.app import App
from kivy.uix.button import Label
import os
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'
# add the following 2 lines to solve OpenGL 2.0 bug
#from kivy import Config
#Config.set('graphics', 'multisamples', '0')
class HelloKivy(App):
def build(self):
return Label(text="Hello Kivy World")
helloKivy = HelloKivy()
helloKivy.run()
```
### Test 1
python3 HelloWorld.py
=> ERROR: libmtdev-dev
ERROR Input MTDev is not supported by your version of linux
[OSError: libmtdev.so.1: cannot open shared object file: No such file or directory](https://stackoverflow.com/questions/66621518/oserror-libmtdev-so-1-cannot-open-shared-object-file-no-such-file-or-director)
`sudo apt-get install libmtdev-dev`
### Test 2
python3 HelloWorld.py
=> ERROR: OpenGL 1.4
import os
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'
### Test 3
- Kein Display gefunden
- Variable DISPLAY
- mit MobaXterm (Display ist eig eingerichtet) -> kein Erfolg
- mit Xming -> kein Erfolg
**=> Aufgegeben**
- [[Python TKinter GUI Framework]] ausprobiert und nach einer Minute ein HelloWorld am Laufen gehabt.
- dann in Windows selbst ohne WSL2 nochmaln versucht Kivy zum Laufen zu bringen => mit Erfolg - siehe [[Python Kivy GUI Framework#02 Python und Kivy installieren in Windows]]
##
***
Related:
- [[Python]]
- [[$-Software|Software]]