Nugget Post : Running Kivy + SL4A’s Python for Android together using QPython

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 - python for android
QPython – python for android

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:


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()

Advertisement
Privacy Settings

3 thoughts on “Nugget Post : Running Kivy + SL4A’s Python for Android together using QPython

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.