PyQt4 in Maemo Fremantle

Check out the new site at https://rkblog.dev.

To run PyQt4 on Maemo - Nokia N900 operating system you need to either use the device or install SDK and Scratchbox on your computer (32-bit Linux best). How to do it can be found on maemo.org. To install the SDK you have to use a GUI installer (if it works, not for me), or two bash scripts that download and install most of the packages.

Maemo SDK and Xephyr installation

Download install scripts from Nokia web page. Run the scratchbox installer:
maemo-scratchbox-install_5.0.sh -s /path/
Where the "path" is a filesystem path where the scratchbox will be installed (common is /scratchbox or /opt/scratchbox). The script will download and install packages. Next run the SDK install script with the same path
maemo-sdk-install_5.0.sh -s /path/

SDK Configuration

As root add you normal user to Scratchbox:
*/scratchbox/sbin/sbox_adduser USERNAME
Next start the service:
*/scratchbox/sbin/sbox_ctl start
As normal user login to scratchbox:
*/scratchbox/login
If you have permission problems chown the login executable:
chown USERNAME */scratchbox/login
When you login to Scratchbox you are in the Maemo system, where you can install packages with apt-get (Debian based distro). On start you can select arch for the SDK in sb-menu. Select i386 for now.
scratchbox1

Xephyr X server

Xephyr is a light X server which is available with base X.org package or as a separate package. To run Maemo we start a small window - Xephyr server - in which the system will show up. To run Xephyr execute:
Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac

Installing Nokia packages

We need to instal Nokia proprietary packages to use Maemo. Go to Nokia page and agree to their terms. You will get a code snippet with a token to the proprietary repository. Add it to /etc/apt/sources.list and execute:
apt-get update
fakeroot apt-get install nokia-binaries nokia-apps

Running Maemo in Xephyr

Login to Scratchbox and execute to start the OS in running Xephyr:
export DISPLAY=:2
af-sb-init.sh start
fmaemo1

PyQt4 and other extra packages

When you have everything ready - login to Scratchbox and add extras repository if you didn't. Add to /etc/apt/sources.list:

deb http://repository.maemo.org/extras-devel/ fremantle free non-free
And after that run apt-get update. Using apt-cache search you can search for packages. PyQt4 currently is python2.5-qt4. There is also PySide, PyGTK and wxPython available. To run PyQt4 or other Python application inside Maemo you need to launch the system in Xephyr from one terminal, and in second one - login to Scratchbox and run the script - it should show up in Xephyr.

PyQt4 in Maemo 5 Fremantle

Using python2.5 run your PyQt4 scripts. Most of them should work (I had few segfaults). Here is a simple example of QWebPage (webkit) in action on Maemo and on desktop Linux:
maemo4
maemo5
Note that not all widgets have their mobile version:
maemo6
RkBlog

PyQt and GUI, 16 February 2010


Check out the new site at https://rkblog.dev.
Comment article
Comment article RkBlog main page Search RSS Contact