Home >Backend Development >Python Tutorial >What tools do you use to make apps in Python?
Using python to develop apps requires the use of a module of python - kivy. kivy is an open source, cross-platform Python development framework for developing innovative applications.
In short, this is a python desktop program development framework (similar to wxpython and other modules). The powerful thing is that kivy supports linux, mac, windows, android, ios platforms , which is why this module is needed to develop apps. (Recommended learning: Python video tutorial)
Although kivy is cross-platform, if you want to use python code on different platforms, you also need to package the python code into an executable for the corresponding platform program, fortunately there is a packaging tool project under the kivy project – buildozer. This is the officially recommended packaging tool because it is relatively simple and has a high degree of automation. Other projects such as: python-for-android can also play a similar role, here No introduction.
kivy develops the first python app
After installing kivy, you can develop the app program. Here is a demonstration of the hello-world program. The more complex usage of kivy is not the focus of this article and will be written later. introduce.
1) Create a main.py file and write:
#! -*- coding:utf-8 -*-from kivy.app import Appclass HelloApp(App): passif __name__ == '__main__': HelloApp().run()
2) Create a hello.kv file and write:
Label: text: 'Hello, World! I am nMask'
Simple explanation: main.py is the entry function , defines a HelloApp class, which inherits kivy.app; the hello.kv file is a kivy program, which is equivalent to defining the interface style, etc. The naming rule of this file is that the class name is lowercase and app is removed.
Install buildozer tool
Buildozer, a tool for easily packaging Android and iOS apps. It automates the entire build process and downloads everything needed to package the application in advance, such as python-for-android, Android SDK, NDK, etc.
Through the above coding, I created my first python app program. This program can run directly on mac, linux, and windows platforms. So how do I make it run on Android or Apple phones? We know that to run on Android, it needs to be packaged into an apk installation program, so we need to use the buildozer tool mentioned earlier.
For more Python related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of What tools do you use to make apps in Python?. For more information, please follow other related articles on the PHP Chinese website!