Nesnelerin interneti (Internet of Things, IoT) konusunda uzun zamandır projeler geliştiriyorum. Bunları yaparken birçok farklı teknolojiyle birlikte çalışmak gerekebiliyor. Sağladığı yenilikleri ve kolaylıkları da göz önüne alınca birçok farklı ve üretken fikrin de her geçen gün ortaya çıktığına şahit oluyoruz. Projeleri gerçekleştirirken düşük maliyetli çözümler arasında yer alan ESP8266 modülü ile ilgili Türkçe yazılmış bir kitap bulamayınca, ben yazmaya karar verdim. Basılı, uzun ve detaylı bir hali önümüzdeki aylarda hazır olacak, ama bu süreçte kaynak ihtiyacı duyanların başlangıç yapabilmesi, hatta daha ileriye giderek ThingSpeak üzerinden grafikler çizdirip, sensör verilerini Tweet atan uygulamalar yapabilmelerini sağlayan örnekleri hazırladım.
In a previous post, installing Kivy on Ubuntu 15.04 was issued. Today, there is a main development which is using SDL2 instead of Pygame. You can find why this is significant on Google.
I cannot find Kivy and Buildozer installion document for Fedora 22 and decided to write a recipe for it. So, lets get started. You will find 8 main sections for this topic:
- Installing Dependencies
- Creating Virtual Environment
- Installing Some Required Python Modules
- Installing Kivy
- Testing Kivy
- Installing Dependencies Required to Packaging for Android
- Configuring Buildozer
- Making APK File
In many applications, a login system is applied. As a result of this, in a Kivy course, we believe that we should teach how to make a basic login system with Kivy. To achieve this, the code in following is written. After the login, the program connects to OpenWeatherMap with its API and gets a data from given coordinates in code. After getting data, it shows the temperature in the logged-in screen. There is also a screen that is shown if the username or password does not match.
In this example, we improved and reviewed the code we have written in the previous post. Screen, ScreenManager and Builder are also used in this example, too. The code is:
In this part of course, you will find how to make applications for desktop or mobile consisting of two or more different screens. There can be menus, tutorials, question-answer sessions or any other requirements that can be solved with multiple screens. We utilize ScreenManager shipped with kivy for this purpose. The code is:
In this example, a code changing background color of application according to slider position is written. In Kivy, color values are changing from 0 to 1 and as a result floating point numbers are used in order to give color value to canvas.
At the sixth part of the course, we are talking about text input and handling the text in text input box. To make a input chance to the user, TextInput class can be used. Here, a login system is made by making username and password check and afterwards, print the result to the console. Python file: #-*-coding:utf-8-*- from kivy.app import App from kivy.uix.gridlayout import GridLayout from kivy.uix.textinput import TextInput from kivy.
At the fifth part of Kivy course, properties and Clock are introduced and an example counter application is made. This application counts with seconds and have abilities to start, pause and reset the timer.
This part is continuing with BoxLayout class of Kivy. BoxLayout is another common layout which is used frequently. It supports both vertical and horizontal orientations and size hints to spare the widgets at specific ratios. The Python code is: from kivy.app import App from kivy.uix.boxlayout import BoxLayout class RootWidget(BoxLayout): pass class kutuApp(App): def build(self): return RootWidget() if __name__ == "__main__": kutuApp().run() And the Kivy Language file is: <RootWidget>: orientation: "vertical" BoxLayout: size_hint_y: 0.
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: "