pythonaro.com

Pythonaro blog

09 March 2010

The joys of Python and Qt

I'm currently working on a tutorial regarding MeeGo, the new Linux-based embedded platform born by the merging of (Nokia-sponsored) Maemo and (Intel-adopted) Moblin. MeeGo is probably the closest thing we'll ever get to a real "Linux for the masses": differently from Android, where Linux is just a kernel for Java to run on top, here we'll have the full GNU toolchain, X display, desktop technologies based on FreeDesktop standards, RPM packages, etc etc.

The main development toolkit for MeeGo, from now on, will officially be QT. This seems to fly in the face of reason, having two existing GTK-based codebases from both "parent" systems which have already been deployed on production devices, but it's actually a very smart choice, as I was reminded just today.

This morning, I was working on a laptop running Windows XP. I built a couple of forms with Qt Designer, then fired up my trusty IDE and wrote the main code, about 150 lines of Python that will download some files, manage a few controls and then display a web page.

After completing a full set of tests on the local machine, I copied it to my (Maemo) phone, and again it was working perfectly -- without any change, recompilation, deployment, anything. Then I went home and copied it back to a different laptop running Kubuntu Linux, and again it was running just fine. Had I had a Mac (or iPad?) laying around, I'm confident it would have run there as well without any change. Consider that the version of QT and PyQt was slightly different on all machines, just to give it a further twist.

Obviously this level of portability has a price. I had to write my code using constructs like QSettings and QNetworkAccessManager rather than messing directly with the Windows Registry or HTTP_PROXY variables. I have yet another (leaky) abstraction layer on top of the OS, which may or may not be to everyone's taste, and the program runs in a sandboxed runtime, which might be slower than natively-compiled code (although this is debatable, these days); but I didn't have to write three different codepaths for each and every interoperation with the OS. I didn't have to worry about having a $HOME or a %HOME%. If I have to worry about packaging is just because I have to write about the ins and outs of a particular platform; in other circumstances I could have simply relied on python tools to do the right thing.

Python and QT could finally deliver the dream of portability that Java promised, if only we give them a sporting chance.

Labels: , , , ,

posted by GiacomoL @ 8:30 PM   0 comments links to this post

03 March 2010

CallBlocker for Maemo

Last week, Vinu Thomas came up with an ingenious script that will silently drop calls on your N900 if they come from a list of "blocked" callers. I never thought you could do that, but apparently there have been quite a few apps for this sort of things on more established platforms like Symbian and iPhone.

At first I suggested a few minor improvements to the script, then I thought I might as well repackage it in a proper application with a proper GUI. I asked permission to Vinu (something the author of "pycallblocker" didn't bother to do), and then I went ahead and put it on Garage.

So there you have it: CallBlocker 1.0 for Maemo 5. Note that it relies on the python2.5-qt4-gui package, currently available only in the extras-testing repository.

The current feature-set is quite limited: you basically enter a list of phone numbers, and callers (exactly) matching them will be sent a busy signal or redirected to voicemail.

It did get quite a warm reception on talk.maemo.org, so I'm motivated to keep development ongoing (at the expense of other, still-unreleased stuff I have almost ready). The current plan is to release a 1.1 version with support for suffix wildcards (e.g. entering +441234*, all numbers beginning with +441234 would be matched and dropped) and better daemon management. Then, time permitting, I'd like to have a 2.0 with features like blocking all withheld/private numbers, blocking SMS texts, blocking specific contacts from address book, blocking all numbers not in addressbook, blocking only during some hours, and possibly even a "whitelist" mode.

Once it reaches a certain maturity, I'll probably consider moving it to the Ovi Store, at which point PyQt licensing issues might arise, but we'll cross that bridge when we get to it.

Labels: , , , ,

posted by GiacomoL @ 3:25 PM   0 comments links to this post

09 February 2010

Mobile applications for Nokia phones with... javascript ?!?

A few days ago the lovely folks at NSManchester, an Apple user group, gave a chance to "the enemy" (i.e. Nokia) to present their technology stack and business strategies for attracting developers.

The two presenter were a bit underwhelming (understandable after they went through the usual, hellish experience with British railway services), and there was little talk of my beloved Maemo, but it's hard to dismiss the technology stack they have chosen to go forward. Key element seems to be the QT library they acquired last year, which I know and love through the original Python bindings. It's powerful and as cross-platform as it can be, with a lot of mindshare in the Linux and Windows communities; this said, it's still C++, and it's hard to get excited about C++ these days. Also, the runtime will gradually appear on new and recent phones but probably won't make it to older ones.

The second development platform they are pushing, however, was more of a surprise to me. Apparently, you can use JavaScript to write applications for recent smartphones (S60 5th ed. -- N97 and 5800 -- and S60 3rd ed. FP2 -- e.g. E72, N85, N96 etc). You can access GPS coordinates, contacts and calendar items, as well as having complete freedom to design the UI with standard HTML and CSS. You don't need to sign the resulting packages, the barrier to entry is lowered dramatically. This is potentially a game-changer, and I don't know why Nokia are not shouting it from the rooftops. Early adopters include Netflix, which uses a basic JavaScript interface to stream their Flash content (!) -- so yes, you can use flash as well. My head simply went "boom"; I must look into this stuff.

One other thing I noticed was the presenters' style, typically European: self-deprecation and brutal honesty about things that work and ones that don't. It was refreshing, after weeks of Yanks propaganda from Google and Apple pushing their new gadgets as "fantastic", "amazing", "revolutionary" etc etc etc...

Labels: , , , , , ,

posted by GiacomoL @ 8:16 AM   0 comments links to this post

25 January 2010

How the Nokia N900 is improving my life

(Small things, but...)

Today I had to took my car to the garage, so had to tell my manager I'd likely be late (public transport is not terrible in our area, but it still takes me about twice the time to get to the office than it would with the car). I'm also down with a laryngitis and I can barely whisper.

I could have booted my home laptop to send an email or IM, but meanwhile the bus would have come and gone. So I hit the road anyway, and thought I would somehow email from the phone.

But then, the Nokia N900 is no Blackberry; it's a full-fledged linux desktop in your pockets. When I enabled the 3G data connection, the button nearby was the one to set your IM status(es) to Online; so I fired that up, looked up my manager in the wonderfully integrated address book, and she was online, so while I sit on the bus, we had a friendly chat about things to do, without having to share them with other commuters or strain my poor throat.

All the while, I was listening to the latest Python 411 podcast about the (apparently terrific and currently-slashdotted) Sikuli project, updating expenses on the little program I've developed (which I'll upload to the Ovi Store in a few weeks, I promise), and browsing Google Reader. The 30-mins commute was over in what seemed like seconds, and the experience was basically the same I could have had while sitting at my desk with a regular laptop.

This little thing is simply outstanding. Apple's new "iWhatever" better have a SIM slot, or they can kiss goodbye to their iPhone marketshare.

Labels: , , , , ,

posted by GiacomoL @ 11:18 AM   1 comments links to this post