Kivy is the next python framework I went discovering, but I really missed the convenient “droid” package that SL4A had. SL4A made it so easy to use native android features… like “Toasts”. With Kivy, (at the moment at least – devs are hard at work to fix this!) it’s a bit tougher – you need to directly access the Java classes for building a Toast by using pyjinius. It would be awesome to have the GUI powers of Kivy, with the native functionality access of SL4A. Qpython gives you exactly that!

Qpython seems to be an evolution of SL4A… it’s really easy to use, see the code snippet below to combine both Kivy and SL4A features:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidhelper | |
from kivy.app import App | |
from kivy.uix.button import Button | |
class TestApp(App): | |
def buttonPress(self,instance): | |
droid = androidhelper.Android() | |
line = droid.dialogGetInput() | |
s = 'Hello %s' % line.result | |
droid.makeToast(s) | |
def build(self): | |
btn1 = Button(text='Hello world 1') | |
btn1.bind(on_press=self.buttonPress) | |
return btn1 | |
TestApp().run() |
3 thoughts on “Nugget Post : Running Kivy + SL4A’s Python for Android together using QPython”