Peter Hansen is sharing code with you
Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.
Don't show this againhg clone https://bitbucket.org/microcode/bbx-python/wiki
Welcome
Welcome to the "Python for BBX" project site.
This project is focused on building up an environment to let anyone write Python apps for the PlayBook. Initial work is focused on a Python launcher implemented as a native "stub" app which creates a Python 3.2 interpreter. The runtime is included in the PlayBook 2.0 beta OS, so the app uses only a small stub and the bundled Python code.
Here's a sample of the code you can already run in the first version of the launcher:
from qnx import audio
def run():
vol = audio.AudioVolume()
v = vol.get_output_level()
# if we're muted, boost volume a bit
if v < 1:
v.set_output_level(25)
player = audio.AudioPlayer()
player.play('shared/misc/soundfile.wav')
Quick Start Instructions
Here's the 60 second version of how to use this.
- Install the latest launcher from the Downloads page. You'll need the DDPB Installer or one of the PlayBook SDKs to deploy it to your tablet, or you can download and use LocalBar if you've already got that installed.
- Launch the app and give it Files permission. It should exit almost immediately, because it's looking for a Python script that doesn't exist on your tablet yet.
- Browse to
shared/documents/bbxrun.logand check that it contains a few lines, including a traceback complaining aboutImportError: No module named bbxrun. - Create
shared/documents/bbxrun.pywith some Python 3.2 code. The functionrun()will be the one invoked by the launcher, but you can have it call anything else and do anything Python can do. Here's a sample starting file:
import time
def run():
data = open('/base/svnrev').read()
print('Your OS has SVN revision:', data)
time.sleep(2)
This is merely a small start, so please help us build a community! You don't need to do any work, just participate in the discussion or even just show moral support by your presence.
Documentation
None yet! Aside from this wiki, all we've got to go on are the "doc strings" extracted from the Python3.2 site-packages folder on the 2.0 beta PlayBook.
We do have some SampleCode however, so give that a shot and add your own!
There are also rudimentary and likely incomplete BuildInstructions for the launcher, using the source code in the launcher/ folder of the repository.
Contact us:
- on freenode.net in the IRC channel #bbx-python
- on Twitter with hash-tag #bbx-python (or follow @peter9477
- email at bbx-python "at" microcode.ca
- suggestions for other places? an early post in comp.lang.python (the python mailing list) deafened us with the lack of enthusiasm, but if you missed that one and think there's some interest there, let us know
This revision is from 2011-11-27 08:38