Skip to content

Commit d4f8ce9

Browse files
committed
Add chapter "What can QPython do?"
1 parent f87b36b commit d4f8ce9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1159
-438
lines changed

docs/CNAME

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
www.qpython.org
1+
www.qpython.org

docs/_sources/en/contributorshowto.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/_sources/en/guide.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ If you you want to know more about how to program through qpython, just follow t
1818
.. toctree::
1919
:maxdepth: 2
2020

21-
qpyprograms
22-
qeditor4web
23-
sl4aapis
24-
callqpyapiinapp
21+
guide_program
22+
guide_ide
23+
guide_libraries
24+
guide_extend
2525

2626

2727
QPython Hackers' Guide
@@ -38,4 +38,4 @@ Welcome to join QPython contributors team
3838
.. toctree::
3939
:maxdepth: 2
4040

41-
contributorshowto
41+
guide_contributors
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
How to contribute
2+
===============================
3+
As a young group, we need your help.
4+
5+
Please send email to us(support at qpython.org) to introduce youself, which part do you want to contribute.
6+
7+
Then we will consider to invite you to join the qpython-collaborator group.
8+
9+
Thanks for supporting this project, let us push on this greate project moving on altogether!
10+
11+
12+
How to write documentation
13+
----------------------------------------
14+
15+
How to translate
16+
----------------------------------------
17+
18+
How to organise a local qpython user sharing event
19+
----------------------------------------------------
20+
21+
How to launch a local QPython users community
22+
---------------------------------------------
23+
24+
How to develop qpython built-in programs
25+
----------------------------------------
26+
27+
How to became QPython core dev team member
28+
----------------------------------------
29+
30+
How to sponsor QPython project
31+
----------------------------------------
32+
33+
34+
35+
More detail coming soon...

docs/_sources/en/guide_howtostart.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
QPython: How To Start
24
========================
35
Now, I will introduce the QPython's features through it's interfaces.
@@ -129,6 +131,3 @@ It will redirect to the QPython.org, including somthe source of this documentati
129131

130132

131133
`Thanks dmych offer the first draft in his blog <http://onetimeblog.logdown.com/posts/2014/01/22/qpython-how-to-start>`_
132-
133-
134-

docs/_sources/en/guide_program.txt

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
What can QPython do?
2+
====================================
3+
4+
5+
Why should I choose QPython
6+
------------------------
7+
QPython offer **an amazing developing experience**, Now you could write & test & run your programs from your anroid, not the PC, Laptop.
8+
9+
We think QPython's programming style may become popular in the future.
10+
11+
QPython's main features
12+
-------------------------
13+
You can do most jobs through QPython just like the way that Python does on PC/Laptop.
14+
15+
16+
**Libraries**
17+
18+
- QPython supports most stardard Python libraries.
19+
20+
- QPython supports many 3rd Python libraries which implemented with pure Python code.
21+
22+
- QPython supports some Python libraries mixed with C/C++ code which pre-compiled by QPython develop team.
23+
24+
- QPython allows you put on the libraries by yourself.
25+
26+
Besides these, QPython offers some extra features which Python doesn't offer, Like:
27+
28+
- Android APIs Access(Like SMS, GPS, NFC, BLUETOOTH etc)
29+
30+
*Why QPython require so many permissions?*
31+
32+
QPython need these permissions to access Android's API.
33+
34+
35+
**Runtime modes**
36+
37+
QPython supports several runtime modes for android.
38+
39+
**Console mode**
40+
41+
It's the default runtime mode in QPython, it's very common in PC/laptop.
42+
43+
44+
**Kivy mode**
45+
46+
QPython supports `Kivy <http://kivy.org>`_ as the GUI programming solution.
47+
48+
49+
Kivy is an open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.
50+
51+
Your device should support opengl2.0 for supporting kivy mode.
52+
53+
By insert into the following header in your script, you can let your script run with kivy mode.
54+
55+
::
56+
57+
#qpy:kivy
58+
59+
60+
If your library require the opengl driver, you shoule declare the kivy mode header in your script, like the jnius.
61+
62+
*NOTE: QPython3 didn't support this mode yet*
63+
64+
**WebApp mode**
65+
66+
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.
67+
68+
WebApp will start a webview in front, and run a python web service background.
69+
You could use *bottle*(QPython built-in library) to implement the web service, or you could install *django* / *flask* framework also.
70+
71+
72+
By insert into the following header in your script, you can let your script run with webapp mode.
73+
74+
::
75+
76+
#qpy:webapp:<app title>
77+
#qpy:<fullscreen or remove this line>
78+
#qpy://<ip:port:path>
79+
80+
For example
81+
82+
::
83+
84+
#qpy:webapp:Hello QPython
85+
#qpy://localhost:8080/hello
86+
87+
88+
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.
89+
90+
91+
::
92+
93+
#qpy:webapp:Hello Qpython
94+
#qpy://127.0.0.1:8080/
95+
"""
96+
This is a sample for qpython webapp
97+
"""
98+
99+
from bottle import Bottle, ServerAdapter
100+
from bottle import run, debug, route, error, static_file, template
101+
102+
103+
######### QPYTHON WEB SERVER ###############
104+
105+
class MyWSGIRefServer(ServerAdapter):
106+
server = None
107+
108+
def run(self, handler):
109+
from wsgiref.simple_server import make_server, WSGIRequestHandler
110+
if self.quiet:
111+
class QuietHandler(WSGIRequestHandler):
112+
def log_request(*args, **kw): pass
113+
self.options['handler_class'] = QuietHandler
114+
self.server = make_server(self.host, self.port, handler, **self.options)
115+
self.server.serve_forever()
116+
117+
def stop(self):
118+
#sys.stderr.close()
119+
import threading
120+
threading.Thread(target=self.server.shutdown).start()
121+
#self.server.shutdown()
122+
self.server.server_close() #<--- alternative but causes bad fd exception
123+
print "# qpyhttpd stop"
124+
125+
126+
######### BUILT-IN ROUTERS ###############
127+
@route('/__exit', method=['GET','HEAD'])
128+
def __exit():
129+
global server
130+
server.stop()
131+
132+
@route('/__ping')
133+
def __ping():
134+
return "ok"
135+
136+
137+
@route('/assets/<filepath:path>')
138+
def server_static(filepath):
139+
return static_file(filepath, root='/sdcard')
140+
141+
142+
######### WEBAPP ROUTERS ###############
143+
@route('/')
144+
def home():
145+
return template('<h1>Hello {{name}} !</h1><a href="/assets/qpython/projects/WebApp Sample/main.py">View source</a><br /><br /> <a href="http://wiki.qpython.org/doc/program_guide/web_app/">>> About QPython Web App</a>',name='QPython')
146+
147+
148+
######### WEBAPP ROUTERS ###############
149+
app = Bottle()
150+
app.route('/', method='GET')(home)
151+
app.route('/__exit', method=['GET','HEAD'])(__exit)
152+
app.route('/__ping', method=['GET','HEAD'])(__ping)
153+
app.route('/assets/<filepath:path>', method='GET')(server_static)
154+
155+
try:
156+
server = MyWSGIRefServer(host="127.0.0.1", port="8080")
157+
app.run(server=server,reloader=False)
158+
except Exception,ex:
159+
print "Exception: %s" % repr(ex)
160+
161+
162+
163+
.. image:: ../_static/guide_program_pic1.png
164+
:alt: QPython WebApp Sample
165+
166+
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.
167+
168+
169+
**Q mode**
170+
171+
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:
172+
173+
::
174+
175+
#qpy:qpyapp

docs/_sources/en/qpyprograms.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)