Now Python is able to run on Android platform thanks to Scripting Layer for Android and Python for Android project. But the User Interface Facade is hard to use. Most of the time, more than one call is needed to achieve your simplest goal. And the fullShow call in FullScreenUI need a XML style layout.
But what if you want to control the layout by programming, or change the layout dynamically at run time? I need a more elegant UI library, that is why DroidUi.
Let's start with Hello world
example,
import DroidUi # yes, you need it
layout = DroidUi.DroidUi() # layout object comes first
hello = DroidUi.Button(layout, # add this Button to the layout
text = 'Hello, DroidUi!', # set the button text
command = layout.quit) # quit the layout when button clicked
layout.mainloop() # enter mainloop
Run this example will give you a big button full of your screen, click button will quit this example.
There are mainly two kinds of object in DroidUi
:
- layout objects: container of View, can be showed. (
DroidUi.DroidUi
) - View objects: UI element, like View class in Android. (
DroidUi.View
)
DroidUi also support showing a layout from a existing XML layout,
use DroidUi.DroidUi.fromxml()
and DroidUi.DroidUi.fromfile()
to get the layout object
- an Android device.
- Scripting Layer for Android r6 or above installed.
- Python for Android r5 or above installed.
- make sure adb is installed on your computer.
- connect your Android device to your computer.
- run install.bat(on Windows) or install.sh(on Linux).
- then DroidUi installed.
DroidUi is licensed under GPLv3 by Tommy Alex