BBX Python: Quick Update #1

Posted:   |  More posts about PlayBook Python BBPyProject

Here are a few quick notes on what's happened with BBX-Python since the last update.

Core: Launcher

I stripped almost everything out of the launcher, leaving it as just the bare bones required to initialize the Python interpreter and run the main script.

That meant taking out all the OpenGL code, along with everything to do with screen contexts, event handling, and other BPS stuff.

This brought it down to under 24K for the native code portion of the launcher, but had the unfortunate side effect of triggering the OS app police, which terminates any app which doesn't post a window update within 30s of launching.

User Interface

I looked into using PyOpenGL but it appears we have only OpenGL ES on the PlayBook, and the author of PyOpenGL (Mike Fletcher) tells me that it's likely non-trivial to modify/port PyOpenGL to work with it. The two are apparently quite similar, but have enough differences that it could be quite a pain. I'll leave this on the back-burner until later, or until I learn more.

In the interim, we've got the QNX Dialog support, and full Notifications support. The dialog demo code is doing system modal dialogs, which is a pain, but I wouldn't expect it's hard to make that non-modal at which point it should prove to be quite usable.

I've also integrated the minimal app requirements into, so that it no longer times out after 30s and gets turfed by the OS.

It shouldn't be a huge amount of work to get some basic bitmap stuff going with the img/img.h functions, so that's high on the list of todos. With some third-party bitmap library (PIL?), either pure Python or ported to QNX, we could probably do some decent basic UIs using just bitmaps.


I've added some ctypes wrapper modules for much of bps/bps.h (and siblings) and all of screen/screen.h. This allowed doing the "minimal app requirements" above: create screen context, window, buffer, post one update to window.

There's code integrated into the latest to set this up, and simplistic demo code in to rapidly flash the screen different colours.

The bps and screen modules also allow event handling, so I threw in an quickly, just to verify it will work. No real problems with that, but it will need an Event class and subclasses added to wrap all these events. No idea how people actually write apps using the low-level C stuff this is all built on... or maybe nobody really does. Anyway, the Python version will be much easier on the eyes, brain, and fingers.

Next Priorities

I think I'll probably attack the following things next, in order:

  1. Basic bitmap support through img/img.h, at least part of it. Goal will be to display at least full-screen bitmaps, preferably including smaller bitmaps at arbitrary positions. Could go pretty far with just that.
  2. Event class and a core App class that can provide the basic event-handling loop, and allow the rest of the app to be written as event-driven code in conventional fashion. This stuff is mostly tedious but straightforward. I'll need to add some more ctypes wrappers; for now I'm doing that manually but in the long run it will be better handled with some automated conversion of the header files. The ctypeslib can do that, though it's alpha-stage code and my first attempts at using it failed for various and sundry reasons, when tried on QNX, Windows, or Linux. I've done this before for other projects, and it's not terribly hard; it should be even easier in this case because the QNX header files are quite consistent and clean.
  3. With those two things, one could actually write some simple apps. That will push the focus back to the BBX-Python core and the launcher, plus tools. Next step will be to make the launcher able to run code specified in an environment variable (that gets into the MANIFEST.MF Entry-Point), and make a basic tool to generate .bar files combining the canned launcher code plus the developer's Python code. That would probably constitute completion of the first phase of this project...

What else? Now's a good time to start chiming in with some comments here, or discussion on the #bbx-python IRC chat on (go to if you don't have an IRC client installed, and join the #bbx-python channel.

Alternatively, follow the #bbx-python hash tag on Twitter to stay abreast of progress.

Note that one purpose of this project is to make visible the existence of a potential Python/PlayBook community: if you're interested but staying silent, you're working against your own interests! Speak up and be seen!


As of June 2012, we've renamed this the BlackBerry-Py Project. You can follow news about it at @BBPyProject and the web site has moved too.

Comments powered by Disqus