In this section, layouts are introduced with more details and images of them are shown. Grid layout is one of the most known widgets and the code may be found below. The main Python file: from kivy.app import App from kivy.uix.gridlayout import GridLayout class RootWidget(GridLayout): pass class izgaraApp(App): def build(self): return RootWidget() if __name__ == "__main__": izgaraApp().run() And the Kivy Language file which should be named as izgara.kv: <RootWidget>: cols: 3 rows: 2 Button: text: "
At the second part of the course, more buttons are added to root widget and Kivy Language is utilized while adding them. From this part, view section of the codes are seperated in a .kv file. You can find the codes below. Our main python file: from kivy.app import App from kivy.uix.boxlayout import BoxLayout class RootWidget(BoxLayout): pass class uygulamaApp(App): def build(self): return RootWidget() if __name__ == "__main__": uygulamaApp().run() Name this as uygulama.
At the first code of the Kivy course consists of a button which covers the entire screen and does nothing. You can just click the button and see that it is clicked with interaction. The code is: from kivy.app import App from kivy.uix.button import Button class BenimUygulamamApp(App): def build(self): return Button(text="Buton", font_size="50sp") if __name__ == "__main__": BenimUygulamamApp().run() Detailed explanation will be added soon.
Kivy has a video player which supports common requirements such as play,pause and stop buttons and images, texts can be used as subtitles or displaying messages to user, streching etc. For the full list, you can check here.
In the previous post, how to install Kivy and Buildozer on Ubuntu is examined. In this post, you will find stages making APK files on Ubuntu with Python and Kivy using Buildozer. If you have followed the previous tutorial, you have already installed Buildozer on your virtual environment; however, it is not ready to making APK files for now. To test this statement, create a folder with a very basic main.py file(example from Kivy.org mainpage):
Installing Kivy and building an apk file is the fundamental step of coding Android applications with Python. In this post, Buildozer is used for building apk, installing sdk, ndk and other dependencies automatically.
All commands on this post are applied on a fresh installed and newly updated (02/07/2015) Ubuntu 15.04. Use it at your own risk.
In this example, three independent sliders are used to control background color and they are in order of red, green and blue. All the values are written at the buttom of the application window in the precision of 0.001. You can change the precision in .kv file if you want. The color is sent by Kivy’s automatic property binding mechanism to Canvas Color and Label.
Working with kivy often requires writing canvas codes which are managing the appearance before, during and after the content is drawn. In this example, one Kivy Slider is used for getting color value between 0 and 1 and in the same time there is a Kivy Label which contains Slider’s value and updated automatically with the help of automatic property binding on Kivy.
In this post, you are able to find an example of Kivy Framework consists of a button and two text label in a boxlayout oriented vertically. There are two files and both are required to run this program. This program is suitable for both mobile and desktop versions of Kivy and has ability to resume at gaining focus when screen is locked or for another reason the program is put in background.
Kivy Framework sayesinde, 2 veya 3 boyutlu uygulama ve oyunların Python ve Kivy dillerinde programlanması ve platform bağımsız olarak çalıştırılabilmeleri mümkün olmakta. Bu yazıda Raspbian kullanıcıları için, Raspberry Pi için desteği sonradan gelen Kivy Framework’ün nasıl kurulacağını bulabilirsiniz.