diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 00000000..51f1a321
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,4 @@
+# These are supported funding model platforms
+
+patreon: riverfor
+custom: ["https://paypal.me/qpyriver"]
diff --git a/.gitignore b/.gitignore
index f0a3a345..1c454d72 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,29 @@
*.iml
.gradle
build
+__MACOSX
.idea
-gradle
+keystore
.DS_Store
+local.properties
+*.apk
+qbaselib.iml
+.*
+!/.gitignore
+gradle-wrapper.properties
+Android.mk
+qpython/src/main/jni/python/libpython2.7.b
+qpysdk/src/main/obj
+values-fr
+values-tr
+build.gradle.new
+captures
+old.git
+qpython/qpython.key
+qpython/cn/release/output.json
+qpython/od/release/*
+qpython/cn
+qpython/google
+qpython/os
+qpython/ol
+qpython/op
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..441d4c0b
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,12 @@
+[submodule "qbaselib"]
+ path = qbaselib
+ url = git@github.com:qpython-android/qbaselib.git
+[submodule "qftplib"]
+ path = qftplib
+ url = git@github.com:qpython-android/qftplib.git
+[submodule "qpysdk/src/main/jni"]
+ path = qpysdk/src/main/jni
+ url = git@github.com:qpython-android/pygamesdl2-jni.git
+[submodule "qpysl4a"]
+ path = qpysl4a
+ url = git@github.com:qpython-android/qpysl4a.git
diff --git a/README.md b/README.md
index 175bb688..9912213e 100644
--- a/README.md
+++ b/README.md
@@ -1,40 +1,79 @@
-# QPython v2
+# About
-Welcome to join QPython project. It's a great project. QPython has got several millions users in the world.
-## background
+
-- QPython is one great app. in Android for all kinds of Pythonist
-- base QPython we can:
- - Pythonic done self script working in Android mobile implementor
- - Pythonic create prototype app. in Android mobile implementor
- - Pythonic show what is pythonic in Android mobile implementor
- - Pythonic teching people enjoy Python in Android mobile implementor
- - etc.
+Welcome to the QPython project!
-- and in fact, QPython's maker just only 1 Chinese guys
+QPython is the Python engine for android. It contains some amazing features such as Python interpreter, runtime environment, editor and QPYI and integrated SL4A. It makes it easy for you to use Python on Android. And it's FREE.
- - and all not full time develop for QPython
- - so means we not enough resource to managment such as:
+Compared with other Python apps, QPython mainly solves how to use Python to drive your Android device work. Good SL4A support is our main goal, such as android's camera, sensor, sms media APIs etc.
- - blog
- - mailling-list
- - IRC
- - Twitter
- - Facebook
- - etc.
+QPython already has millions of users worldwide and it is also an open source project.
+For different usage scenarios, QPython has two branches, namely QPython Ox and 3x.
-## Note
+QPython Ox is mainly aimed at programming learners, and it provides more friendly features for beginners.
+QPython 3x is mainly for experienced Python users, and it provides some advanced technical features.
-It's not the google play's qpython app's sourcecode, because the online version sourcecode is not friendly, so I decide to rebuild code, Now it only has the python core and console module.
+## Quick start
-It will be published with the Apache v2 license.
+This repository is the QPython Ox project repository, you can follow the below steps to run it.
-## Welcome to contribute
+- Macos + Android studio, (Ubuntu may work too)
+- git clone git@github.com:qpython-android/qpython.git
+- git submodule init
+- git submodule sync
+- git submodule update
+- build it...
-Please to join us to push on the great project.
+Get more information from [wiki](https://github.com/qpython-android/qpython/wiki) for developing QPython
-You can folk and send pull request to us,
+## Related
-Please add skype riverfor for discussing how to move on.
+- [QPython 3x features](https://github.com/qpython-android/qpython.org/blob/master/qpython-docs/source/en/qpython_3x_featues.rst), [QPython Ox features](https://github.com/qpython-android/qpython.org/blob/master/qpython-docs/source/en/qpython_ox_featues.rst)
+- [QPySL4A APIs](https://github.com/qpython-android/qpysl4a/blob/master/doc/en/APIs.rst) and [test scripts](https://github.com/qpython-android/qpysl4a/issues/1)
+- QPYPI Packages
+
+## How to ask QPython related questions
+In order to benefit those guys who have the same issue with QPython, we suggest that you should ask the issue which is related with QPython within public techical communities.
+
+
+### English QPythonista Community
+
+- [Ask in stackoverflow](https://stackoverflow.com/questions/tagged/qpython)
+- [Discuss QPython Programming in QPython Group](https://www.facebook.com/groups/qpython/)
+
+### Chinese QPythonista Community
+
+- [在segmentfault提问 - Chinese](https://segmentfault.com/t/qpython)
+- [在贴吧讨论 - Chinese](https://tieba.baidu.com/f?ie=utf-8&kw=qpython)
+
+### Report issues
+
+Please tell us your phone's informatioin, android os information, QPython branch, and your code, where did you install it and the detailed stituation you have encountered.
+
+- [Report an app's issue](https://github.com/qpython-android/qpython/issues)
+- [Report an non-app's issue](https://github.com/qpython-android/qpython.org/issues)
+- [Request to support a package](https://github.com/qpython-android/qpypi/issues)
+
+## Donation
+
+- harford (Wechat)
+- 晨晖 (Wechat)
+
+THANK YOU VERY MUCH FOR DONATION!
+
+
+## How to contribute
+WE NEED YOUR HELP AND CONTRIBUTE, WE WILL BE VERY GRATEFUL IF YOU CAN TELL US YOUR IDEA OR SUGGESTION.
+
+IF YOU WANT TO PARTICIPATE THIS PROJECT, PLEASE SEND YOUR EMAIL TO US, WE WILL INVITE YOU INTO QPYTHON SLACK GROUP WHERE WE WILL DISCUSS HOW TO PUSH ON QPYTHON.
+
+- Email: support@qpython.org
+- Twitter: @qpython
+- Facebook: https://www.facebook.com/qpython
+
+Or you can join [qpython slack](https://join.slack.com/t/qpython/shared_invite/enQtOTI1MDY1NzM4NjU2LTljZDI3MjI0ZmZmNzIwNzAwMTU2ZDIyNGRjMTJiOTQ4MzgzY2Y3NDU5YzJjNTQ5MmM4Nzk2MGI4YWZmY2VhOTU)
+
+THANK YOU.
diff --git a/build.gradle b/build.gradle
index d769076f..d576ffd4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,31 +1,52 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
+def supportVersion = "28.0.0" // equals to line60
+def retrofitVersion = "2.1.0"
+def rxVersion = "1.2.1"
-//task wrapper(type: Wrapper) {
-// ersion = '2.2.1'
-// gradleV
-// distributionUrl = 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip'
-//}
+def okhttpVersion = '3.10.0'
+
+def butterknifeVersion = '9.0.0' //eqals to line 26
buildscript {
repositories {
jcenter()
+ google()
mavenCentral()
+
+ maven { url "https://plugins.gradle.org/m2/" }
+ maven { url "https://maven.google.com" }
}
+
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.0'
- classpath 'me.tatarka:gradle-retrolambda:3.2.5'
- classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
- classpath "io.realm:realm-gradle-plugin:1.1.1"
- classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
- classpath "io.realm:realm-gradle-plugin:3.0.0"
+ classpath 'com.android.tools.build:gradle:3.5.3'
+
+ // A gradle plugin for getting java lambda support in java 6, 7 and android
+ // https://github.com/evant/gradle-retrolambda
+ classpath 'me.tatarka:gradle-retrolambda:3.7.0'
+
+ // Gradle plugin which downloads and manages your Android SDK.
+ //classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
+
+ // Field and method binding for Android views which uses annotation processing to generate boilerplate code for you.
+ // https://github.com/JakeWharton/butterknife
+ classpath "com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2"
+
+ // Realm is a mobile database: a replacement for SQLite & ORMs
+ // https://github.com/realm/realm-java
+ classpath "io.realm:realm-gradle-plugin:3.5.0"
+
+ classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
jcenter()
+ google()
+
+ mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://dl.bintray.com/azeesoft/maven' }
+ //maven { url "http://mvn.leancloud.cn/nexus/content/repositories/public" }
}
}
@@ -33,12 +54,65 @@ task clean(type: Delete) {
delete rootProject.buildDir
}
-
subprojects {
def androidHome
-
if ((androidHome = System.env.'ANDROID_HOME')
&& (androidHome = androidHome as File).exists()
- && androidHome.canWrite())
- apply plugin: 'android-sdk-manager'
+ && androidHome.canWrite()) {
+ //apply plugin: 'android-sdk-manager'
+ }
+
+ project.configurations.all {
+ resolutionStrategy.eachDependency { details ->
+ if (details.requested.group == 'com.android.support'
+ && !details.requested.name.contains('multidex')) {
+ details.useVersion "${supportVersion}"
+ }
+ }
+
+ }
}
+
+ext {
+ libOkHttp3 = "com.squareup.okhttp3:okhttp:${okhttpVersion}"
+
+ libRxJava = "io.reactivex:rxandroid:${rxVersion}"
+ libRxAndroid = "io.reactivex:rxjava:${rxVersion}"
+ libFileDownloaderLib = 'com.liulishuo.filedownloader:library:0.3.5'
+
+ libSupportV4 = "com.android.support:support-v4:${supportVersion}"
+ libSupportV4Design = 'com.android.support:design:${supportVersion}'
+
+ libSupportV7 = "com.android.support:appcompat-v7:${supportVersion}"
+ libSupportCardView = "com.android.support:cardview-v7:${supportVersion}"
+
+ libSupportPreference = "com.android.support:preference-v14:${supportVersion}"
+ libSupportAnnotation = "com.android.support:support-annotations:${supportVersion}"
+ libSupportDesign = "com.android.support:design:${supportVersion}"
+ libOkHttp3Log = "com.squareup.okhttp3:logging-interceptor:${okhttpVersion}"
+
+ minSdkVersion = 14
+ targetSdkVersion = 28
+ compileSdkVersion = 28
+ buildToolsVersion = '28.0.3'
+
+ // firebase related https://firebase.google.com/docs/android/setup
+ firebaseCore = "com.google.firebase:firebase-core:16.0.6"
+ firebaseMsg = "com.google.firebase:firebase-messaging:17.3.4"
+ firebaseAuth = "com.google.firebase:firebase-auth:16.1.0"
+ firebaseDatabase = "com.google.firebase:firebase-database:16.0.5"
+
+ // https://developers.google.com/android/guides/setup
+ googlePlayServiceAuth = "com.google.android.gms:play-services-auth:16.0.1"
+
+ leakcanaryDebug = 'com.squareup.leakcanary:leakcanary-android:1.5.4'
+ leakcanaryRelease = 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
+ libGoogleGuava = 'com.google.guava:guava:18.0'
+
+ retrofit = "com.squareup.retrofit2:retrofit:${retrofitVersion}"
+ retrofitCoverterGson = "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
+ retrofitAdapterRxjava = "com.squareup.retrofit2:adapter-rxjava:${retrofitVersion}"
+
+ libButterknife = "com.jakewharton:butterknife:${butterknifeVersion}"
+ libButterknifeCompiler ="com.jakewharton:butterknife-compiler:${butterknifeVersion}"
+}
\ No newline at end of file
diff --git a/debug.keystore b/debug.keystore
new file mode 100644
index 00000000..70dc936c
Binary files /dev/null and b/debug.keystore differ
diff --git a/docs/.buildinfo b/docs/.buildinfo
deleted file mode 100644
index ede477ec..00000000
--- a/docs/.buildinfo
+++ /dev/null
@@ -1,4 +0,0 @@
-# Sphinx build info version 1
-# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
-config: 73c1a81a8979635c625f3371149742eb
-tags: 645f666f9bcd5a90fca523b33c5a78b7
diff --git a/docs/CNAME b/docs/CNAME
deleted file mode 100644
index 4632497e..00000000
--- a/docs/CNAME
+++ /dev/null
@@ -1 +0,0 @@
-www.qpython.org
diff --git a/docs/QPython_3x_featues.md b/docs/QPython_3x_featues.md
new file mode 100644
index 00000000..491234b5
--- /dev/null
+++ b/docs/QPython_3x_featues.md
@@ -0,0 +1,36 @@
+# QPython 3x featues
+
+Because google play and some appstores have strict requirements on the permissions of the app, we use different strategies in different appstores, which is why the branch name will be different. For example, L means Limited, and S means it contains Sensitive permissions.
+
+## Python
+- Python3.6.6
+- QRCode Reader
+- Editor
+- QPYPI
+- Ftp
+
+## Android Permissions
+
+### Both QPython 3S and 3L
+
+- android.permission.INTERNET
+- android.permission.ACCESS_SUPERUSER
+- android.permission.WAKE_LOCK
+- android.permission.ACCESS_NETWORK_STATE
+- android.permission.ACCESS_WIFI_STATE
+- android.permission.RECEIVE_BOOT_COMPLETED
+- android.permission.CAMERA
+- android.permission.FLASHLIGHT
+- android.permission.VIBRATE
+- android.permission.RECEIVE_USER_PRESENT
+- com.android.vending.BILLING
+- com.android.browser.permission.READ_HISTORY_BOOKMARKS
+- com.android.browser.permission.WRITE_HISTORY_BOOKMARKS
+- com.android.launcher.permission.INSTALL_SHORTCUT
+- com.android.launcher.permission.UNINSTALL_SHORTCUT
+- android.permission.READ_EXTERNAL_STORAGE
+- android.permission.WRITE_EXTERNAL_STORAGE
+- android.permission.ACCESS_COARSE_LOCATION
+- android.permission.ACCESS_FINE_LOCATION
+
+### QPython 3S
diff --git a/docs/QPython_Ox_featues.md b/docs/QPython_Ox_featues.md
new file mode 100644
index 00000000..fdfb8c09
--- /dev/null
+++ b/docs/QPython_Ox_featues.md
@@ -0,0 +1,40 @@
+# QPython Ox featues
+
+Because google play and some appstores have strict requirements on the permissions of the app, we use different strategies in different appstores, which is why the branch name will be different. For example, L means Limited, and S means it contains Sensitive permissions.
+
+## Python
+- Python3 + Python2 basis
+- QRCode Reader
+- Editor
+- QPYPI
+- Ftp
+- Course
+
+## Permissions
+### Both QPython OL and OS
+- android.permission.INTERNET
+- android.permission.ACCESS_SUPERUSER
+- android.permission.WAKE_LOCK
+- android.permission.ACCESS_NETWORK_STATE
+- android.permission.ACCESS_WIFI_STATE
+- android.permission.RECEIVE_BOOT_COMPLETED
+- android.permission.CAMERA
+- android.permission.FLASHLIGHT
+- android.permission.VIBRATE
+- android.permission.RECEIVE_USER_PRESENT
+- com.android.vending.BILLING
+- com.android.browser.permission.READ_HISTORY_BOOKMARKS
+- com.android.browser.permission.WRITE_HISTORY_BOOKMARKS
+- com.android.launcher.permission.INSTALL_SHORTCUT
+- com.android.launcher.permission.UNINSTALL_SHORTCUT
+- android.permission.READ_EXTERNAL_STORAGE
+- android.permission.WRITE_EXTERNAL_STORAGE
+- android.permission.ACCESS_COARSE_LOCATION
+- android.permission.ACCESS_FINE_LOCATION
+
+### QPython OS
+- android.permission.FOREGROUND_SERVICE
+- android.permission.BLUETOOTH
+- android.permission.BLUETOOTH_ADMIN
+- android.permission.NFC
+- android.permission.RECORD_AUDIO
diff --git a/docs/README.md b/docs/README.md
new file mode 100644
index 00000000..42a966ab
--- /dev/null
+++ b/docs/README.md
@@ -0,0 +1,2 @@
+# About
+QPython documentation
diff --git a/docs/_sources/en/guide.txt b/docs/_sources/en/guide.txt
deleted file mode 100644
index 211cb8d4..00000000
--- a/docs/_sources/en/guide.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-QPython Getting started
-==========================
-How to start quickly ? Just follow the following steps:
-
-.. toctree::
- :maxdepth: 2
-
- guide_howtostart
- guide_helloworld
-
-
-Programming Guide
-========================
-
-If you you want to know more about how to program through qpython, just follow these steps:
-
-
-.. toctree::
- :maxdepth: 2
-
- guide_program
- guide_ide
- guide_libraries
- guide_extend
-
-
-QPython Hackers' Guide
-=======================
-
-* `QPython Hackers Howto `_
-
-
-Contributors' Guide
-===================
-
-Welcome to join QPython contributors team
-
-.. toctree::
- :maxdepth: 2
-
- guide_contributors
diff --git a/docs/_sources/en/guide_contributors.txt b/docs/_sources/en/guide_contributors.txt
deleted file mode 100644
index 11ad7a21..00000000
--- a/docs/_sources/en/guide_contributors.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-How to contribute
-===============================
-As a young group, we need your help.
-
-Please send email to us(support at qpython.org) to introduce youself, which part do you want to contribute.
-
-Then we will consider to invite you to join the qpython-collaborator group.
-
-Thanks for supporting this project, let us push on this greate project moving on altogether!
-
-
-How to write documentation
-----------------------------------------
-
-How to translate
-----------------------------------------
-
-How to organise a local qpython user sharing event
-----------------------------------------------------
-
-How to launch a local QPython users community
----------------------------------------------
-
-How to develop qpython built-in programs
-----------------------------------------
-
-How to became QPython core dev team member
-----------------------------------------
-
-How to sponsor QPython project
-----------------------------------------
-
-
-
-More detail coming soon...
diff --git a/docs/_sources/en/guide_extend.txt b/docs/_sources/en/guide_extend.txt
deleted file mode 100644
index 34131435..00000000
--- a/docs/_sources/en/guide_extend.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-How to call QPython script in your application?
-=====================================================
-You could call QPython to run some script or python code in your app
-
-::
-
- String extPlgPlusName = "org.qpython.qpy"; // QPython package name
- Intent intent = new Intent();
- intent.setClassName(extPlgPlusName, "org.qpython.qpylib.MPyApi");
- intent.setAction(extPlgPlusName + ".action.MPyApi");
-
- Bundle mBundle = new Bundle();
- mBundle.putString("app", "myappid");
- mBundle.putString("act", "onPyApi");
- mBundle.putString("flag", "onQPyExec"); // any String flag you may use in your context
- mBundle.putString("param", ""); // param String param you may use in your context
-
- /*
- * The String Python code, you can put your py file in res or raw or intenet, so that you can get it the same way, which can make it scalable
- */
- String code = "#qpy:console\n" +
- "try:\n" +
- " import androidhelper\n" +
- "\n" +
- " droid = androidhelper.Android()\n" +
- " line = droid.dialogGetInput()\n" +
- " s = 'Hello %s' % line.result\n" +
- " droid.makeToast(s)\n" +
- "except:\n" +
- " print(\"Hello, Please update to newest QPython version from (http://play.qpython.com/qrcode-python.html) to use this feature\")\n");
-
-
- mBundle.putString("pycode", code);
- intent.putExtras(mBundle);
-
- startActivityForResult(intent, SCRIPT_EXEC_PY);
-
- ...
-
-
- // Deal with the result callback by qpython
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == SCRIPT_EXEC_PY) {
- if (data!=null) {
- Bundle bundle = data.getExtras();
- String flag = bundle.getString("flag");
- String param = bundle.getString("param");
- String result = bundle.getString("result"); // Result your Pycode generate
- Toast.makeText(this, "onQPyExec: return ("+result+")", Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(this, "onQPyExec: data is null", Toast.LENGTH_SHORT).show();
-
- }
- }
- }
-
-
-
-Sample of running QPython script in other application
--------------------------------------------------------
-* `You can see this sample project in github `_
-
-* `Another Application which have published in google play - QPython Plugin for Tasker `_
-
-.. image:: ../_static/taskerplugin-for-qpython.png
-
-How to build an independt APK from QPython scripts?
-=====================================================
-http://qpy.io
-
diff --git a/docs/_sources/en/guide_helloworld.txt b/docs/_sources/en/guide_helloworld.txt
deleted file mode 100644
index d07001f6..00000000
--- a/docs/_sources/en/guide_helloworld.txt
+++ /dev/null
@@ -1,121 +0,0 @@
-Writing "Hello World"
-========================
-
-
-Hello world
-----------------
-.. image:: ../_static/guide_helloworld_pic1.png
- :alt: hello world
-
-Well, after you became a bit more familiar with QPython, let's create our first program in QPython. Obviously, it will be `helloworld.py`. ;)
-
-Start QPython, open editor and enter the following code:
-
-::
-
- import androidhelper
- droid = androidhelper.Android()
- droid.makeToast('Hello, Username!')
-
-No wonder, it's just similar to any other hello-world program. When executed, it just shows pop-up message on the screen (see screenshot on the top). Anyway, it's a good example of QPython program.
-
-SL4A library
-------------
-
-It begins with *import androidhelper* — the most useful module in QPython, which encapsulates almost all interface with Android, available in Python. Any script developed in QPython starts with this statement (at least if it claims to communicate with user). Read more about Python library `here `_ and import statement `here `_
-
-By the way, if you're going to make your script compatible with SL4A, you should replace the first line with the following code (and use `android` instead `androidhelper` further in the program):
-
-::
-
- try:
- import androidhelper as android
- except ImportError:
- import android
-
-Ok, next we're creating an object `droid` (actually a class), it is necessary to call RPC functions in order to communicate with Android.
-
-And the last line of our code calls such function, `droid.makeToast()`, which shows a small pop-up message (a "toast") on the screen.
-
-Well, let's add some more functionality. Let it ask the user name and greet them.
-
-More samples
----------------
-We can display a simple dialog box with the title, prompt, edit field and buttons **Ok** and **Cancel** using `dialogGetInput` call. Replace the last line of your code and save it as `hello1.py`:
-
-::
-
- import androidhelper
- droid = androidhelper.Android()
- respond = droid.dialogGetInput("Hello", "What is your name?")
-
-Well, I think it should return any respond, any user reaction. That's why I wrote `respond = ...`. But what the call actually returns? Let's check. Just add `print` statement after the last line:
-
-::
-
- import androidhelper
- droid = androidhelper.Android()
- respond = droid.dialogGetInput("Hello", "What is your name?")
- print respond
-
-Then save and run it...
-
-Oops! Nothing printed? Don't worry. Just pull notification bar and you will see "QPython Program Output: hello1.py" — tap it!
-
-
-As you can see, `droid.dialogGetInput()` returns a JSON object with three fields. We need only one — `result` which contains an actual input from user.
-
-Let's add script's reaction:
-
-::
-
- import androidhelper
- droid = androidhelper.Android()
- respond = droid.dialogGetInput("Hello", "What is your name?")
- print respond
- message = 'Hello, %s!' % respond.result
- droid.makeToast(message)
-
-Last two lines (1) format the message and (2) show the message to the user in the toast. See `Python docs `_ if you still don't know what `%` means.
-
-Wow! It works! ;)
-
-Now I'm going to add a bit of logic there. Think: what happen if the user clicks **Cancel** button, or clicks **Ok** leaving the input field blank?
-
-You can play with the program checking what contains `respond` variable in every case.
-
-First of all, I want to put text entered by user to a separate variable: `name = respond.result`. Then I'm going to check it, and if it contains any real text, it will be considered as a name and will be used in greeting. Otherwise another message will be shown. Replace fifth line `message = 'Hello, %s!' % respond.result` with the following code:
-
-::
-
- name = respond.result
- if name:
- message = 'Hello, %s!' % name
- else:
- message = "Hey! And you're not very polite, %Username%!"
-
-Use **<** and **>** buttons on the toolbar to indent/unindent lines in if-statement (or just use space/backspace keys). You can read more about indentation in Python `here `_; if-statement described `here `_.
-
-First of all, we put user input to the variable `name`. Then we check does `name` contain anything? In case the user left the line blank and clicked **Ok**, the return value is empty string `''`. In case of **Cancel** button pressed, the return value is `None`. Both are treated as false in if-statement. So, only if `name` contans anything meaninful, then-statement is executed and greeting "Hello, ...!" shown. In case of empty input the user will see "Hey! And you're not very polite, %Username%!" message.
-
-Ok, here is the whole program:
-
-::
-
- import androidhelper
- droid = androidhelper.Android()
- respond = droid.dialogGetInput("Hello", "What is your name?")
- print respond
- name = respond.result
- if name:
- message = 'Hello, %s!' % name
- else:
- message = "Hey! And you're not very polite, %Username%!"
- droid.makeToast(message)
-
-
-`Thanks dmych offer the first draft in his blog `_
-
-
-
-
diff --git a/docs/_sources/en/guide_howtostart.txt b/docs/_sources/en/guide_howtostart.txt
deleted file mode 100644
index 8575d63e..00000000
--- a/docs/_sources/en/guide_howtostart.txt
+++ /dev/null
@@ -1,133 +0,0 @@
-
-
-QPython: How To Start
-========================
-Now, I will introduce the QPython's features through it's interfaces.
-
-1. Dashboard
-------------------
-
-.. image:: ../_static/guide_howtostart_pic1.png
- :alt: QPython start
-
-
-After you installed QPython, start it in the usual way by tapping its icon in the menu. Screenshot on the top of this post shows what you should see when QPython just started.
-
-**Start button**
-
-By tapping the big button with Python logo in the center of the screen you can
-
-**Launch your local script or project**
-
-*Get script from QR code* (funny brand new way to share and distribute your code, you can create QRCode through `QPython's QRCode generator `_
-
-Now you can install many 3rd libaries ( pure python libraries mainly ) through pip_console.py script.
-
-If you want QPython to run some script of project when you click the start button, you can make it by setting default program in setting activity.
-
-
-**Developer kit dashboard**
-
-If you swipe to the left instead of tapping, you will see another (second) main screen of QPython *(Pic. 2)*. As for me, it is much more useful and comfortable for developer.
-
-.. image:: ../_static/guide_howtostart_pic2.png
- :alt: QPython develop dashboard
-
-
-Tools available here:
-
-* **Console** — yes, it's regular Python console, feel free to comunicate with interpreter directly
-* **Editor** — QPython has a nice text editor integrated with the rest, you can write code and run it without leaving the application
-* **My QPython** — here you can find your scripts and projects
-* **System** — maintain libraries and components: install and uninstall them
-* **Package Index** opens the page `QPyPI `_ in browser allowing to install packages listed there
-* **Community** leads to `QPython.org `_ page. Feel free to join or ask&answer questions in the QPython community.
-
-By long clicking on the console or editor, you have chance to create the shortcut on desktop which allow you enter console or editor directly.
-
-Next, let's see the console and the editor.
-
-2. Console and editor
--------------------------
-
-.. image:: ../_static/guide_howtostart_pic3.png
- :alt: QPython console
-
-
-As I said before, there is an ordinary Python console. Many people usually use it to explore objects' properties, consult about syntax and test their ideas. You can type your commands directly and Python interpreter will execute them. You can open additional consoles by tapping the plus button (1) and usedrop-down list on the upper left corner to switch between consoles (2). To close the console just tap the close button (3).
-
-.. image:: ../_static/guide_howtostart_pic4.png
- :alt: QPython notification
-
-
-Please note, there will be notification in the notification bar unless you explicitly close the console and you always can reach the open console by tapping the notification.
-
-
-
-.. image:: ../_static/guide_howtostart_pic5.png
- :alt: QPython editor
-
-
-The editor allows you obviously (hello Cap!) enter and modify text. Here you can develop your scripts, save them and execute. The editor supports Python syntax highlighting and shows line numbers (there is no ability to go to the line by number though). *(above picture)*
-
-When typing, you can easily control indentation level (which is critical for Python code) using two buttons on the toolbar (1). Next buttons on the toolbar are **Save** and **Save As** (2), then goes **Run** (3), **Undo**, **Search**, **Recent Files** and **Settings** buttons. Also there are two buttons on the top: **Open** and **New** (5).
-
-When saving, don't forget to add `.py` estension to the file name since the editor don't do it for you.
-
-3. Programs
---------------------
-You can find the scripts or projects in My QPython. My QPython contains the scripts and Projects.
-
-By long clicking on script or project, you have chance to create the shortcut for the script or project. Once you have created the shortcuts on desktop, you can directly run the script or project from desktop.
-
-
-**Scripts**
-Scripts : A single script. The scripts are in the /sdcard/com.hipipal.qpyplus/scripts directory.
-If you want your script could be found in My QPython, please upload it to this directory.
-
-When you click the script, you can choose the following actions:
-
-- Run : Run the script
-- Open : Edit the script with built-in editor
-- Rename : Rename the script
-- Delete : Delete the script
-
-**Projects**
-Projects : A directory which should contain the main.py as the project's default launch script, and you can put other dependency 3rd libraries or resources in the same directory, if you want your project could be found in My QPython, please upload them into this directory.
-
-When you click on the project, you can choose the following actions:
-
-- Run : run the project
-- Open : use it to explore project's resources
-- Rename : Rename the project
-- Delete : Delete the project
-
-4. Libraries
---------------
-
-By installing 3rd libraries, you can extend your qpython's programming ability quickly. There are some ways to install libraries.
-
-**QPypi**
-
-You can install some pre-built libraries from QPypi, like numpy etc.
-
-**Pip console**
-
-You can install most pure python libraries through pip console.
-
-
-Besides the two ways above, you could copy libraries into the /sdcard/qpython/lib/python2.7/site-packages in your device.
-
-
-*Notice:*
-Some libraries mixed with c/c++ files could not be install through pip console for the android lacks the compiler environment, you could ask help from qpython developer team.
-
-
-5. Community
---------------
-It will redirect to the QPython.org, including somthe source of this documentation, and there are some qpython user communities' link, many questions of qpython usage or programming could be asked in the community.
-
-
-
-
-`Thanks dmych offer the first draft in his blog `_
diff --git a/docs/_sources/en/guide_ide.txt b/docs/_sources/en/guide_ide.txt
deleted file mode 100644
index 64d5097a..00000000
--- a/docs/_sources/en/guide_ide.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Are there more efficient way for developing?
-===================================================
-
-
-How to program from my cellphone
-----------------------------------------
-* `What editor should I use? `_
-
-How to program from my pc
---------------------------------------
diff --git a/docs/_sources/en/guide_libraries.txt b/docs/_sources/en/guide_libraries.txt
deleted file mode 100644
index 9cbb0099..00000000
--- a/docs/_sources/en/guide_libraries.txt
+++ /dev/null
@@ -1,105 +0,0 @@
-Python builtin Libraries
-==========================
-
-Python 3rd Libraries
-==========================
-
-Android APIs
-==========================
-
-
-SL4A APIs
-=============
-
-.. image:: ../_static/sl4a.jpg
-
-To simplify QPython SL4A development in IDEs with a
-"hepler" class derived from the default Android class containing
-SL4A facade functions & API documentation
-
-
-Structure
-------------
-
-
-QPython NFC json result
-::
-
- {
- "role": , # could be self/master/slave
- "stat": , # could be ok / fail / cancl
- "message":
- }
-
-QPy APIs
-----------
-
-.. py:function:: AndroidHelper.executeQPy(script)
-
- Execute a qpython script by absolute path
-
- :param str script: The absolute path of the qpython script
- :return: boolean
-
-
-NFC APIs
-------------
-NFC Message Beam APIs
-
-.. py:function:: AndroidHelper.dialogCreateNFCBeamMaster()
-
- Create a dialog which can send the message to NFC Beam Slave
-
- :return: QPython NFC json result
-
-.. py:function:: AndroidHelper.NFCBeamMessage(message)
-
- Sendthe message to NFC Beam Slave without dialog
-
- :return: QPython NFC json result
-
-
-.. py:function:: AndroidHelper.dialogCreateNFCBeamSlave()
-
- Create a NFC Beam Slave to wait for the master's beam message
-
- :return: QPython NFC json result
-
-
-Location API
-------------
-
-.. py:function:: androidhelper.getLastKnownLocation
-
-
-::
-
- Droid = androidhelper.Android()
- location = Droid.getLastKnownLocation().result
- location = location.get('network', location.get('gps'))
-
-Sensor API
-------------
-
-.. py:function:: androidhelper.sensorsReadOrientation()
-
-::
-
- Droid = androidhelper.Android()
- Droid.startSensingTimed(1, 250)
- sensor = Droid.sensorsReadOrientation().result
- Droid.stopSensing()
-
-Other SL4A APIs
-----------------
-
-.. py:function:: AndroidHelper.dialogCreateSpinnerProgress(title,message,maximum progress)
-
- Create a spinner progress dialog
-
-.. py:function:: AndroidHelper.webViewShow(url,wait)
-
- Display a WebView with the given URL.
-
- :param str url: URL
- :param boolean wait(Optional): block until the user exits the WebView
diff --git a/docs/_sources/en/guide_program.txt b/docs/_sources/en/guide_program.txt
deleted file mode 100644
index aacd867b..00000000
--- a/docs/_sources/en/guide_program.txt
+++ /dev/null
@@ -1,175 +0,0 @@
-What can QPython do?
-====================================
-
-
-Why should I choose QPython
-------------------------
-QPython offer **an amazing developing experience**, Now you could write & test & run your programs from your anroid, not the PC, Laptop.
-
-We think QPython's programming style may become popular in the future.
-
-QPython's main features
--------------------------
-You can do most jobs through QPython just like the way that Python does on PC/Laptop.
-
-
-**Libraries**
-
-- QPython supports most stardard Python libraries.
-
-- QPython supports many 3rd Python libraries which implemented with pure Python code.
-
-- QPython supports some Python libraries mixed with C/C++ code which pre-compiled by QPython develop team.
-
-- QPython allows you put on the libraries by yourself.
-
-Besides these, QPython offers some extra features which Python doesn't offer, Like:
-
-- Android APIs Access(Like SMS, GPS, NFC, BLUETOOTH etc)
-
-*Why QPython require so many permissions?*
-
-QPython need these permissions to access Android's API.
-
-
-**Runtime modes**
-
-QPython supports several runtime modes for android.
-
-**Console mode**
-
-It's the default runtime mode in QPython, it's very common in PC/laptop.
-
-
-**Kivy mode**
-
-QPython supports `Kivy `_ as the GUI programming solution.
-
-
-Kivy is an open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.
-
-Your device should support opengl2.0 for supporting kivy mode.
-
-By insert into the following header in your script, you can let your script run with kivy mode.
-
-::
-
- #qpy:kivy
-
-
-If your library require the opengl driver, you shoule declare the kivy mode header in your script, like the jnius.
-
-*NOTE: QPython3 didn't support this mode yet*
-
-**WebApp mode**
-
-We recommend you implement WebApp with QPython for it offer the easy to accomplish UI and Take advantage of Python's fast programming strong point.
-
-WebApp will start a webview in front, and run a python web service background.
-You could use *bottle*(QPython built-in library) to implement the web service, or you could install *django* / *flask* framework also.
-
-
-By insert into the following header in your script, you can let your script run with webapp mode.
-
-::
-
- #qpy:webapp:
- #qpy:
- #qpy://
-
-For example
-
-::
-
- #qpy:webapp:Hello QPython
- #qpy://localhost:8080/hello
-
-
-The previous should start a webview which should load the *http://localhost:8080/hello* as the default page, and the webview will keep the titlebar which title is "Hello QPython", if you add the *#qpy:fullscreen* it will hide the titlebar.
-
-
-::
-
- #qpy:webapp:Hello Qpython
- #qpy://127.0.0.1:8080/
- """
- This is a sample for qpython webapp
- """
-
- from bottle import Bottle, ServerAdapter
- from bottle import run, debug, route, error, static_file, template
-
-
- ######### QPYTHON WEB SERVER ###############
-
- class MyWSGIRefServer(ServerAdapter):
- server = None
-
- def run(self, handler):
- from wsgiref.simple_server import make_server, WSGIRequestHandler
- if self.quiet:
- class QuietHandler(WSGIRequestHandler):
- def log_request(*args, **kw): pass
- self.options['handler_class'] = QuietHandler
- self.server = make_server(self.host, self.port, handler, **self.options)
- self.server.serve_forever()
-
- def stop(self):
- #sys.stderr.close()
- import threading
- threading.Thread(target=self.server.shutdown).start()
- #self.server.shutdown()
- self.server.server_close() #<--- alternative but causes bad fd exception
- print "# qpyhttpd stop"
-
-
- ######### BUILT-IN ROUTERS ###############
- @route('/__exit', method=['GET','HEAD'])
- def __exit():
- global server
- server.stop()
-
- @route('/__ping')
- def __ping():
- return "ok"
-
-
- @route('/assets/')
- def server_static(filepath):
- return static_file(filepath, root='/sdcard')
-
-
- ######### WEBAPP ROUTERS ###############
- @route('/')
- def home():
- return template('
>> About QPython Web App',name='QPython')
-
-
- ######### WEBAPP ROUTERS ###############
- app = Bottle()
- app.route('/', method='GET')(home)
- app.route('/__exit', method=['GET','HEAD'])(__exit)
- app.route('/__ping', method=['GET','HEAD'])(__ping)
- app.route('/assets/', method='GET')(server_static)
-
- try:
- server = MyWSGIRefServer(host="127.0.0.1", port="8080")
- app.run(server=server,reloader=False)
- except Exception,ex:
- print "Exception: %s" % repr(ex)
-
-
-
-.. image:: ../_static/guide_program_pic1.png
- :alt: QPython WebApp Sample
-
-In the other part of the code, you could implement a webserver whish serve on localhost:8080 and make the URL /hello implement as your webapp's homepage.
-
-
-**Q mode**
-
-If you don't want the QPython display some UI, pelase try to use the QScript mode, it could run a script background, just insert the following header into your script:
-
-::
-
- #qpy:qpyapp
diff --git a/docs/_sources/index.txt b/docs/_sources/index.txt
deleted file mode 100644
index 5dafba83..00000000
--- a/docs/_sources/index.txt
+++ /dev/null
@@ -1,90 +0,0 @@
-.. QPython documentation master file, created by
- sphinx-quickstart on Fri Apr 7 15:07:35 2017.
- You can adapt this file completely to your liking, but it should at least
- contain the root `toctree` directive.
-
-.. image:: _static/bestpython.png
-
-
-Welcome to read the QPython guide!
-=============================================
-
-QPython is a script engine that runs Python on android devices. It lets your android device run Python scripts and projects. It contains the Python interpreter, console, editor, and the SL4A Library for Android. It’s Python on Android!
-
-
-QPython has several millions users in the world already, it's a great project for programming users, welcome to join us for contributing to this project NOW.
-
-
-What's NEW
-------------------------
-QPython project include the `QPython `_ and `QPython3 `_ applications.
-
-QPython application is using the **Python 2.7.2** , and QPython application is using the **Python 3.2.2** .
-
-
-QPython's newest version is 1.3.0 (Released on 2017/3/20) , QPython3's newest version is 1.0.2 (Released on 2017/3/29), New versions include many amazing features, please upgrade to the newest version as soon from google play, amazon appstore etc.
-
-
-Thanks these guys who are contributing
-----------------------------------------
-They are pushing on the QPython project moving forward.
-
-.. image:: https://avatars0.githubusercontent.com/u/3059527?v=3&s=60
- :target: https://github.com/riverfor
- :alt: River is the project's organizer and the current online QPython's author.
-
-.. image:: https://avatars0.githubusercontent.com/u/10812534?v=3&s=60
- :target: https://github.com/pollyfat
- :alt: Mae is a beautiful and talented girl developer who is good at python & android programming.
-
-.. image:: https://avatars0.githubusercontent.com/u/22494?v=3&s=60
- :target: https://github.com/ZoomQuiet
- :alt: Zoom.Quiet is a knowledgeable guy who is famous in many opensource communities.
-
-.. image:: https://avatars3.githubusercontent.com/u/5159173?v=3&s=60
- :target: https://github.com/kylelk
- :alt: Kyle kersey is a US geek.
-
-.. image:: https://avatars2.githubusercontent.com/u/25975283?v=3&s=60
- :target: https://github.com/liyuanrui
- :alt: liyuanrui is a Chinese geek
-
-
-Do you want to join the great QPython team ? You could `Ask qustions on twitter `_ or `email us `_.
-And you could `fork us on github `_ and send pull request.
-
-
-QPython Communities
-------------------
-**There are many active QPython communities where you could meet the QPython users like you**
-
-* `Join Facebook community `_
-* `Join Google group `_
-* `Join G+ community `_
-* `QPython on Stackoverflow `_
-
-**And you could talk to us through social network**
-
-* `Like us on facebook `_
-* `Follow us on twitter `_
-
-* `Report issue `_
-* `Email us `_
-
-
-**It's the official QPython Users & Contributors' Guide, please follow these steps for using and contributing.**
-
-Now, let's GO
----------------
-.. toctree::
- :maxdepth: 2
-
- en/guide
-
-For Chinese users
----------------
-.. toctree::
- :maxdepth: 2
-
- zhindex
-
diff --git a/docs/_sources/zh/contributorshowto.txt b/docs/_sources/zh/contributorshowto.txt
deleted file mode 100644
index da17ec1e..00000000
--- a/docs/_sources/zh/contributorshowto.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-
-QPython文档体系说明
----------------------
-
-QPython 文档体系分为 英文/中文 两部分,我们努力保持两种语言对应内容的准确和同步,其中内容其中又分为
-
-* 快速开始 (使用上的帮助)
-
-* 编程指南 (主要是用QPython来进行编程和开发的指南)
-
-* QPython黑客指南 (深入折腾的指导)
-
-* 贡献者指南 (QPython贡献者指南,分为在QPython team内的,和以外的)
-
-
-如何提交文档
--------------------------------
-文档非常重要,我们用sphinx来组织文档,并且文档会通过github page功能直接推到qpython.org网站中
-在想要贡献QPython文档之前仔细阅读我们的指南
-
-* git clone http://github.com/qpython-android/qpython
-
-* 进入到 项目的qpython-docs目录中
-
-* 按照sphinx规则编辑source中的文件即可
-
-* 最后cd到qpython-docs中并运行build.sh
-
-* 打开浏览器打开本地文件检查,
-
-* 如果检查无问题则可以提交,然后浏览qpython.org即可看到最新的更新
-
-
-如何提交翻译
--------------------------------
-QPython是一个支持多语言的应用,你可以通过以下方式来提交对应国家的翻译
diff --git a/docs/_sources/zh/howtostart.txt b/docs/_sources/zh/howtostart.txt
deleted file mode 100644
index 8a1ed07f..00000000
--- a/docs/_sources/zh/howtostart.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-快速开始
-=========
-
-* `QPython - 使用说明 `_
-* `QPython - 快速开始 `_
-* `“你好,世界!” `_
-
-编程指南
-============
-
-* `QPython - 开发 WEB APP `_
-* `QPython - Bottle 快速了解 `_
-
-QPython黑客指南
-=================
-
-* `QPython - 编程向导 `_
-* `QPython 黑客 `_
-
-贡献者指南
-=================
-欢迎加入 QPython 团队
-
-.. toctree::
- :maxdepth: 2
-
- contributorshowto
-
diff --git a/docs/_sources/zhindex.txt b/docs/_sources/zhindex.txt
deleted file mode 100644
index 6006633f..00000000
--- a/docs/_sources/zhindex.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-中文用户向导
-=============================================
-
-欢迎 !
-------------------------------
-QPython/QPython3 的最新版本1.3.2(QPython), 1.0.2(QPython3) 已经发布,它包含了许多惊艳的特性,请从应用市场安装
-
-
-QPython 起步
-------------------------
-.. toctree::
- :maxdepth: 2
-
- zh/howtostart
-
-
-更多链接
-------------------------------
-* `常见问题 `_
-* `在百度贴吧里讨论 `_
-* `在微博问我们问题 `_
-* `给我们发邮件 `_
-* `报告问题 `_
-
-QPython 用户开发组
-------------------------------
-* 请加入 `QPython 用户开发者组 `_ 来和全世界的 QPython 用户一块来玩转QPython。
-* 加入QPython QQ组(Q群:540717901)来和中国活跃的QPython 用户一起玩转 QPython
-
-如何贡献
----------
-想成为 QPython 的贡献者么?请 `给我们发邮件 `_
-
diff --git a/docs/en/guide.html b/docs/en/guide.html
deleted file mode 100644
index 4ce17b59..00000000
--- a/docs/en/guide.html
+++ /dev/null
@@ -1,352 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- QPython Getting started — QPython 0.9 documentation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
No wonder, it’s just similar to any other hello-world program. When executed, it just shows pop-up message on the screen (see screenshot on the top). Anyway, it’s a good example of QPython program.
It begins with import androidhelper — the most useful module in QPython, which encapsulates almost all interface with Android, available in Python. Any script developed in QPython starts with this statement (at least if it claims to communicate with user). Read more about Python library here and import statement here
-
By the way, if you’re going to make your script compatible with SL4A, you should replace the first line with the following code (and use android instead androidhelper further in the program):
We can display a simple dialog box with the title, prompt, edit field and buttons Ok and Cancel using dialogGetInput call. Replace the last line of your code and save it as hello1.py:
-
importandroidhelper
-droid=androidhelper.Android()
-respond=droid.dialogGetInput("Hello","What is your name?")
-
-
-
Well, I think it should return any respond, any user reaction. That’s why I wrote respond = .... But what the call actually returns? Let’s check. Just add print statement after the last line:
-
importandroidhelper
-droid=androidhelper.Android()
-respond=droid.dialogGetInput("Hello","What is your name?")
-printrespond
-
-
-
Then save and run it...
-
Oops! Nothing printed? Don’t worry. Just pull notification bar and you will see “QPython Program Output: hello1.py” — tap it!
-
As you can see, droid.dialogGetInput() returns a JSON object with three fields. We need only one — result which contains an actual input from user.
-
Let’s add script’s reaction:
-
importandroidhelper
-droid=androidhelper.Android()
-respond=droid.dialogGetInput("Hello","What is your name?")
-printrespond
-message='Hello, %s!'%respond.result
-droid.makeToast(message)
-
-
-
Last two lines (1) format the message and (2) show the message to the user in the toast. See Python docs if you still don’t know what % means.
-
Wow! It works! ;)
-
Now I’m going to add a bit of logic there. Think: what happen if the user clicks Cancel button, or clicks Ok leaving the input field blank?
-
You can play with the program checking what contains respond variable in every case.
-
First of all, I want to put text entered by user to a separate variable: name = respond.result. Then I’m going to check it, and if it contains any real text, it will be considered as a name and will be used in greeting. Otherwise another message will be shown. Replace fifth line message = ‘Hello, %s!’ % respond.result with the following code:
-
name=respond.result
-ifname:
- message='Hello, %s!'%name
-else:
- message="Hey! And you're not very polite, %Username%!"
-
-
-
Use < and > buttons on the toolbar to indent/unindent lines in if-statement (or just use space/backspace keys). You can read more about indentation in Python here; if-statement described here.
-
First of all, we put user input to the variable name. Then we check does name contain anything? In case the user left the line blank and clicked Ok, the return value is empty string ‘’. In case of Cancel button pressed, the return value is None. Both are treated as false in if-statement. So, only if name contans anything meaninful, then-statement is executed and greeting “Hello, ...!” shown. In case of empty input the user will see “Hey! And you’re not very polite, %Username%!” message.
-
Ok, here is the whole program:
-
importandroidhelper
-droid=androidhelper.Android()
-respond=droid.dialogGetInput("Hello","What is your name?")
-printrespond
-name=respond.result
-ifname:
- message='Hello, %s!'%name
-else:
- message="Hey! And you're not very polite, %Username%!"
-droid.makeToast(message)
-
After you installed QPython, start it in the usual way by tapping its icon in the menu. Screenshot on the top of this post shows what you should see when QPython just started.
-
Start button
-
By tapping the big button with Python logo in the center of the screen you can
-
Launch your local script or project
-
Get script from QR code (funny brand new way to share and distribute your code, you can create QRCode through QPython’s QRCode generator
-
Now you can install many 3rd libaries ( pure python libraries mainly ) through pip_console.py script.
-
If you want QPython to run some script of project when you click the start button, you can make it by setting default program in setting activity.
-
Developer kit dashboard
-
If you swipe to the left instead of tapping, you will see another (second) main screen of QPython (Pic. 2). As for me, it is much more useful and comfortable for developer.
-
-
Tools available here:
-
-
Console — yes, it’s regular Python console, feel free to comunicate with interpreter directly
-
Editor — QPython has a nice text editor integrated with the rest, you can write code and run it without leaving the application
-
My QPython — here you can find your scripts and projects
-
System — maintain libraries and components: install and uninstall them
-
Package Index opens the page QPyPI in browser allowing to install packages listed there
-
Community leads to QPython.org page. Feel free to join or ask&answer questions in the QPython community.
-
-
By long clicking on the console or editor, you have chance to create the shortcut on desktop which allow you enter console or editor directly.
As I said before, there is an ordinary Python console. Many people usually use it to explore objects’ properties, consult about syntax and test their ideas. You can type your commands directly and Python interpreter will execute them. You can open additional consoles by tapping the plus button (1) and usedrop-down list on the upper left corner to switch between consoles (2). To close the console just tap the close button (3).
-
-
Please note, there will be notification in the notification bar unless you explicitly close the console and you always can reach the open console by tapping the notification.
-
-
The editor allows you obviously (hello Cap!) enter and modify text. Here you can develop your scripts, save them and execute. The editor supports Python syntax highlighting and shows line numbers (there is no ability to go to the line by number though). (above picture)
-
When typing, you can easily control indentation level (which is critical for Python code) using two buttons on the toolbar (1). Next buttons on the toolbar are Save and Save As (2), then goes Run (3), Undo, Search, Recent Files and Settings buttons. Also there are two buttons on the top: Open and New (5).
-
When saving, don’t forget to add .py estension to the file name since the editor don’t do it for you.
You can find the scripts or projects in My QPython. My QPython contains the scripts and Projects.
-
By long clicking on script or project, you have chance to create the shortcut for the script or project. Once you have created the shortcuts on desktop, you can directly run the script or project from desktop.
-
Scripts
-Scripts : A single script. The scripts are in the /sdcard/com.hipipal.qpyplus/scripts directory.
-If you want your script could be found in My QPython, please upload it to this directory.
-
When you click the script, you can choose the following actions:
-
-
Run : Run the script
-
Open : Edit the script with built-in editor
-
Rename : Rename the script
-
Delete : Delete the script
-
-
Projects
-Projects : A directory which should contain the main.py as the project’s default launch script, and you can put other dependency 3rd libraries or resources in the same directory, if you want your project could be found in My QPython, please upload them into this directory.
-
When you click on the project, you can choose the following actions:
By installing 3rd libraries, you can extend your qpython’s programming ability quickly. There are some ways to install libraries.
-
QPypi
-
You can install some pre-built libraries from QPypi, like numpy etc.
-
Pip console
-
You can install most pure python libraries through pip console.
-
Besides the two ways above, you could copy libraries into the /sdcard/qpython/lib/python2.7/site-packages in your device.
-
Notice:
-Some libraries mixed with c/c++ files could not be install through pip console for the android lacks the compiler environment, you could ask help from qpython developer team.
It will redirect to the QPython.org, including somthe source of this documentation, and there are some qpython user communities’ link, many questions of qpython usage or programming could be asked in the community.
To simplify QPython SL4A development in IDEs with a
-“hepler” class derived from the default Android class containing
-SL4A facade functions & API documentation
You can do most jobs through QPython just like the way that Python does on PC/Laptop.
-
Libraries
-
-
QPython supports most stardard Python libraries.
-
QPython supports many 3rd Python libraries which implemented with pure Python code.
-
QPython supports some Python libraries mixed with C/C++ code which pre-compiled by QPython develop team.
-
QPython allows you put on the libraries by yourself.
-
-
Besides these, QPython offers some extra features which Python doesn’t offer, Like:
-
-
Android APIs Access(Like SMS, GPS, NFC, BLUETOOTH etc)
-
-
Why QPython require so many permissions?
-
QPython need these permissions to access Android’s API.
-
Runtime modes
-
QPython supports several runtime modes for android.
-
Console mode
-
It’s the default runtime mode in QPython, it’s very common in PC/laptop.
-
Kivy mode
-
QPython supports Kivy as the GUI programming solution.
-
Kivy is an open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.
-
Your device should support opengl2.0 for supporting kivy mode.
-
By insert into the following header in your script, you can let your script run with kivy mode.
-
#qpy:kivy
-
-
-
If your library require the opengl driver, you shoule declare the kivy mode header in your script, like the jnius.
-
NOTE: QPython3 didn’t support this mode yet
-
WebApp mode
-
We recommend you implement WebApp with QPython for it offer the easy to accomplish UI and Take advantage of Python’s fast programming strong point.
-
WebApp will start a webview in front, and run a python web service background.
-You could use bottle*(QPython built-in library) to implement the web service, or you could install *django / flask framework also.
-
By insert into the following header in your script, you can let your script run with webapp mode.
-
#qpy:webapp:<app title>
-#qpy:<fullscreen or remove this line>
-#qpy://<ip:port:path>
-
The previous should start a webview which should load the http://localhost:8080/hello as the default page, and the webview will keep the titlebar which title is “Hello QPython”, if you add the #qpy:fullscreen it will hide the titlebar.
In the other part of the code, you could implement a webserver whish serve on localhost:8080 and make the URL /hello implement as your webapp’s homepage.
-
Q mode
-
If you don’t want the QPython display some UI, pelase try to use the QScript mode, it could run a script background, just insert the following header into your script:
QPython is a script engine that runs Python on android devices. It lets your android device run Python scripts and projects. It contains the Python interpreter, console, editor, and the SL4A Library for Android. It’s Python on Android!
-
QPython has several millions users in the world already, it’s a great project for programming users, welcome to join us for contributing to this project NOW.
QPython project include the QPython and QPython3 applications.
-
QPython application is using the Python 2.7.2 , and QPython application is using the Python 3.2.2 .
-
QPython’s newest version is 1.3.0 (Released on 2017/3/20) , QPython3’s newest version is 1.0.2 (Released on 2017/3/29), New versions include many amazing features, please upgrade to the newest version as soon from google play, amazon appstore etc.
A hands-on introduction to Python for beginning programmers
-
If you are a new guy to QPython, you should watch the tutorial video and just follow the steps to learn how to run script with QPython
-
-
-
-
-
Running with Console
-
Running QPython’s simple script with console model
-
#qpy:2
-#qpy:console
-#qpy:http://qpython.com/s/qpy-sample.py
-
-class Calculator(object):
- #define class to simulate a simple calculator
- def __init__ (self):
- #start with zero
- self.current = 0
- def add(self, amount):
- #add number to current
- self.current += amount
- def getCurrent(self):
- return self.current
-
-myBuddy = Calculator() # make myBuddy into a Calculator object
-myBuddy.add(2) #use myBuddy's new add method derived from the Calculator class
-print(myBuddy.getCurrent()) #print myBuddy's current instance variable
-
-
-
-
-
-
Running with Kivy
-
Running QPython’s script with GUI model ( Kivy library )
-
#qpy:2
-#qpy:kivy
-#qpy:http://qpython.com/s/qpy-guisample.py
-
-from kivy.app import App
-from kivy.uix.button import Button
-
-class TestApp(App):
- def build(self):
- # display a button with the text : Hello QPython
- return Button(text='Hello QPython')
-
-TestApp().run()
-
-
-
-
-
Running as Web App ( QPython needs >= 0.9.7.x )
-
Running Web App with QPython
-
#qpy:2
-#qpy:webapp:Hello Qpython
-#qpy://localhost:8080/hello
-"""
-This is a sample for qpython webapp
-"""
-from bottle import route, run
-
-@route('/hello')
-def hello():
- return "Hello World!"
-
-run(host='localhost', port=8080)