Kivy is a graphical user interface Python library that allows you to develop multiplatform applications on Windows, MacOS, Android, iOS, Linux, and Raspberry Pi. What is better is that it performs better then HTML5 cross platform alternatives. Here I’ll show how to install it on both MacOS and Windows. We will also make a few sample apps to make sure everything works.
All of the instructions follow the video below in print form. The code is down there as well.
If you find videos like this useful consider donating a $1 on Patreon.
[googleplusone]
Instructions & Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# ---------- Install Kivy on Mac ---------- 1. Install Python and PyCharm like I show here : https://youtu.be/nwjAHQERL08?t=37m 2. Download Kivy for Python 3 Kivy-1.9.1-osx-python3.7z here : https://kivy.org/#download 3. In terminal : cd <Directory you Downloaded Kivy> 4. In terminal : sudo mv Kivy2.app /Applications/Kivy.app 5. In terminal : ln -s /Applications/Kivy.app/Contents/Resources/script /usr/local/bin/kivy 6. Test it works in terminal type : kivy and then import kivy 7. Run application by typing in terminal : kivy yourapp.py # ---------- Install Kivy on Windows ---------- 1. Install Python and PyCharm like I show here : https://youtu.be/nwjAHQERL08?t=37m 2. In command prompt : python -m pip install --upgrade pip wheel setuptools 3. In command prompt : python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew 4. In command prompt : python -m pip install kivy.deps.gstreamer --extra-index-url https://kivy.org/downloads/packages/simple/ 5. In command prompt : python -m pip install kivy # ---------- kivytut.py ---------- import kivy kivy.require('1.9.0') from kivy.app import App from kivy.uix.button import Label # Inherit Kivy's App class which represents the window # for our widgets # HelloKivy inherits all the fields and methods # from Kivy class HelloKivy(App): # This returns the content we want in the window def build(self): # Return a label widget with Hello Kivy return Label(text="Hello Kivy") helloKivy = HelloKivy() helloKivy.run() # ---------- kivytut2.py ---------- import kivy kivy.require('1.9.0') from kivy.app import App from kivy.uix.button import Label # Inherit Kivy's App class which represents the window # for our widgets # HelloKivy inherits all the fields and methods # from Kivy class HelloKivyApp(App): # This returns the content we want in the window def build(self): # Return a label widget with Hello Kivy # The name of the kv file has to be hellokivy # minus the app part from this class to # match up properly return Label() hello_kivy = HelloKivyApp() hello_kivy.run() # ---------- hellokivy.kv ---------- # We can separate the logic from the presentation layer <Label>: text: "Hello Kivy" |
Leave a Reply