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 again

microcode / bbx-python http://microcode.ca/bbx-python

Python on the PlayBook and BBX platform. This project is focused on building up various core capabilities 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.

Clone this repository (size: 503.4 KB): HTTPS / SSH
hg clone https://bitbucket.org/microcode/bbx-python
hg clone ssh://hg@bitbucket.org/microcode/bbx-python
hg 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.

  1. 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.
  2. 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.
  3. Browse to shared/documents/bbxrun.log and check that it contains a few lines, including a traceback complaining about ImportError: No module named bbxrun.
  4. Create shared/documents/bbxrun.py with some Python 3.2 code. The function run() 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