Monday, April 16, 2012

Writing android gui using python(introduction)

PythonForAndroid provides support for python script language on android. CLE project supports interaction between python and java, gives a common interface for multiple programming languages. And wrapandroid project encapsulates android java class with cle objects. Using the three components, programmers can write android gui programs with python directly. This article is an introduction. There will have series of articles to further explain how to programming android applications using python.

Preparing environment.
install PythonForAndroid from
CLE may install from network by application automatically, you need only include starcore_android_r5.jar in the project. The file is in, which can be download from
Wrapandroid has two files: wrapandroid.jar and SRPWrapAndroidEngine.xml, which can be download from http:/
Begin programming
Open eclipse, create a new android project, for example, “introduction”
Add Permission, which is used to download and install cle for the application
 Collapse | Copy Code
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
copy files : starcore_android_r5.jar and wrapandroid.jar into the project directory, and add them to java build path, as shown below.

Inline image 1

copy file : SRPWrapAndroidEngine.xml to assets directory.

import com.srplab.wrapandroid.*;
public class IntroductionActivity extends WrapAndroidActivity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        StarActivity._Call("DoAssetsFile", "python", "");

Read more: Codeproject
QR: Inline image 2

Posted via email from Jasper-Net