BlackBerry-Py Preview


Posted:   |  More posts about BB10 Python Tart Cascades PySide PlayBook BBPyProject

Sometimes I write little because nothing's happening, other times because so much is happening I can't stop to write about it! Fortunately the last few weeks have been the second case.

As of June 2012, BBX-Python has been renamed the BlackBerry-Py Project. You can follow news about it at @BBPyProject and the web site has moved too. (Please let me know if you find an old link where I didn't set up a redirect of some kind.)

We thought one good idea would be to try providing a Cascades look-and-feel to the package, so on that front Xitij Ritesh Patel has been preparing some QML Cascades components, with Button, RadioButton, and Slider under way and looking good. Our general goal is to provide some components that look pretty close to Cascades, and act very similarly, as a stepping stone to "real" Cascades support via PySide some time after the first update to the Dev Alpha and beta Cascades NDK. That won't happen automatically, and will likely benefit from contributions by others.

On a related front I started a QML "installed module" that you can access using import BlackBerryPy 0.9 in your QML, and began populating it with a few useful items. One that should prove very handy for making apps which cleanly and elegantly handle re-orientation, not to mention different device resolutions (e.g. PlayBook vs. Dev Alpha), is the KeyboardProxy component. All you need to do with this is create an instance of this in your own QML, with something like KeyboardProxy { id: kb }, and then anchor other elements to the top of it. It provides an Item which tracks the virtual keyboard, going from a height of 0 to the appropriate height whenever the KB is shown onscreen. It also has a "showing" property that you can use to enable/disable other functionality whenever the KB is shown.

I've been digging deep into the plumbing, figuring out how the "blackberry" plugin for Qt works, so I can smooth over some limitations and problems in the Qt port, or fix the trivial ones. In the process I also learned that using showFullScreen() on the QDeclarativeView object is critical to get proper automatic sizing and re-orientation behaviour on mobile platforms, so make sure you're using that and you can avoid things like hardcoding width: 1024; height: 600 in your QML root object. (You also need view.setResizeMode(view.ResizeMode.SizeRootObjectToView)) but that was more widely understood.)

I've also made a branch where I added support for handling window state changes (thumbnail, hidden, fullscreen) and basic app state (active, inactive), using a secondary BPS event handling thread. This will allow us to use the qnx.dialog Python package to do non-system-modal dialogs (we can already do system-modal ones but nobody should be using those in their apps). Unfortunately there's no version of the Qt port yet which both works properly with that and doesn't have laggy scrolling (QTBUG-26177) so those nice features need to wait for a fix.

I think the KDAB guys are going to be on top of it this week though, so with any luck we'll have that resolved by the Toronto BB10 Jam on June 21. Be sure to find me or Ritesh (HorizonXP) while we're there!

Code Samples

If you missed out on our mention of the QML LiveView sample, you need to check that out! There's a signed copy on the download page. It lets you browse to the shared/ folders and open a .qml file for viewing (i.e. rendered, not just viewing the source). It monitors the folder for changes to any .qml file found there, and reloads the main .qml when it sees changes. Errors are reported as well. This tool has accelerated my QML work by probably five times, and I can't recommend strongly enough the benefits of testing on-device this way. I know there are similar features in Momentics and Qt Creator but there's no substitute for seeing and touching it right on the device, in real time.

Ritesh also finished up the first usable version of the BB-Py Twitter sample and that's in his sub-repo on Bitbucket.

I also added a simple Keyboard sample to demonstrate the effectiveness and use of the aforementioned KeyboardProxy component.

BlackBerry Community Wiki

Lastly, the project even has a mention in the new BlackBerry Community Wiki on the Python page which, I hope, will help build a community for the project.

When Will It Be Ready?

Ah, well, that's an excellent question. I'm glad you asked it! :-)

As far as I'm concerned, it's ready now. In addition to the sample apps released (3), we've got more in the works. I've personally ported two of my unreleased AIR apps (which had stalled months ago because, honestly, AIR isn't Python) and last week wrote from scratch a complete app in about one day, using QML LiveView to accelerate the UI development and of course Python for all the backend stuff (mainly some persistence, in this case). This is all while continuing to learn QML and Qt, from the high levels down to the lowest level plumbing, investigating Qt (blackberry plugin) issues, and so on. Imagine how fast I'd be going right now were I to focus solely on writing apps!

It's ready. It works. UI in QML, logic in Python. We're building apps with it now, and so can you.

(A more formal/official "launch" is still to come. I think we'd probably wait until the laggy scrolling issue is fixed in Qt. The binaries of the Qt libraries we're using are currently based on 4.8.2 so we're missing some of the niceties mentioned above with non-modal dialogs and window state change events, but that's no reason not to start building apps.)

Comments powered by Disqus