Coding for Nokia 770 using Python - Misc Notes
It is time to make a post about some great input that I’ve gotten from the readers of my blog. Thanks to everyone who has made comments. Keep on commenting people.
Ok, first of all thanks to Kasper Souren for pointing out that if you are having “permission denied” problems, or otherwise problems running the downloaded scripts, you sould do a “chmod +x *.py” in the folder where you have the script in.
Also big thanks to Martin N for giving a nice example on how to make the python script fully hildonized by adding it to the start menu and also how to get the icon to the task list while your app is running. Here’s what he wrote…
Hi Teemu, I’ve found a solution in the Maemo SDK Tutorial:
Based on this I created the following two files for your example:
uitest.desktop:
[Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Name=UITest Exec=/home/user/python/uitest.py X-Osso-Service=example.uitest Icon=qgn_list_gene_default_appexample.uitest.service:
[D-BUS Service] Name=example.uitest Exec=/home/user/python/uitest.py…and created those links:
ln -s /home/user/python/uitest.desktop /var/lib/install/etc/others-menu/extra_applications/ uitest.desktop ln -s /home/user/python/example.uitest.service /var/lib/install/usr/lib/dbus-1.0/services/ example.uitest.serviceActually you don’t need the desktop file to have an icon in the task list, but I think it makes the hildonization complete.
![]()
Edit: Please note that the version parameter in the .desktop file refers to the desktop entry specification version instead of the application version. Thanks to Karo for pointing this out.
February 14th, 2006 at 5:18 pm
Hi Teemu,
it is common misunderstanding that the Version key in the desktop entry refers to application version, but it refers to the desktop entry specification version!
Use can check it from here in the table 2: Standard keys
http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-0.9.4.html
It would really make my day if you could mention about it in a blog entry, otherwise the injustice keep getting worse and worse!
Thanks!
-Karo L
February 14th, 2006 at 5:56 pm
Thanks Karo… that was really valuable piece of information. I just added that note to the blog entry.
February 14th, 2006 at 11:17 pm
Hm, I assume that means that the version parameter of osso_initialize() is unrelated to Version entry, right?
February 15th, 2006 at 2:02 pm
I have Fedora 4 installed and would like to install the scratchbox in my PC. Does an rpm exist somewhere so I could install the scratchbox. I have bad experiences in using the gz packages in the past.
February 15th, 2006 at 2:44 pm
Hi John,
I’m afraid that there are no .rpm packages for maemo SDK available. However, if you follow the instructions on maemo site I think it should work on Fedora as well.
Everything is basically installed in /scratchbox directory and if you want to uninstall the SDK you can just remove that directory. Someone correct me if I’m wrong here?
February 15th, 2006 at 4:37 pm
tf, indeed they are unrelated. You’re supposed to use application’s version number in osso_initialize.
There actually isn’t yet final version of the desktop entry specification, but it seems to be safe to use 1.0 for now in the .desktop file.
February 21st, 2006 at 8:18 am
[…] Hooray for Teemu’s blog. Now I know how to make the application icon show up! […]
February 26th, 2006 at 6:23 pm
Hello!
Finally after huge problems I have my pymaemo working! After 2 weeks of trying to get fakeroot working I gave up using ubuntu directly. Apparently fakeroot had problems with my network connections (which are… hmm slighly abnormal in my opinion). Now I use VMWare player with ready image of ubuntu and I installed maemo and pymaemo perfectly! I’ve allready made simple programs with python and driven them in Xephyr screen, everything works perfectly. Now it’s time to move on with my project and start serious pythoning!
Do you have any recommondations for which editor (or even IDE) to use in programming? This blog is great, keep up posting!
February 26th, 2006 at 10:03 pm
Hi morical,
Nice to hear that you’ve got the system up and running. Now the fun part starts when you can really start the coding.
I can’t really recommend IDEs. As an editor I use emacs. What comes to IDEs, Eclipse is my favourite, but I haven’t used it much for Python coding. As a matter of fact, I cannot even do much coding, since I’ve been doing my studies quite a lot recently. I’m trying to get more people into doing the software and then just picking up the fruits.
So let me know once you get something interesting ready.
March 5th, 2006 at 1:04 am
Hi,
if there is a problem with finding »normal« eXecuteable files on your Nokia 770, you should edit a file named:
~/.profile
This file should have the following content (two lines):
PATH=/var/lib/install/usr/bin:/var/lib/install/usr/local/bin:/var/lib/install/bin:$PATH
export PATH
So you will be able to use the »standard« shebang at the first line in every Python-Program (and it works on other platforms too, without changing a piece of code):
#!/usr/bin/env python2.4
It would be nice, if you just propagate this, because all other würgarounds are not satisfying, imho.
TNX for gathering information about Python on 770.
Ludger
March 6th, 2006 at 12:34 pm
Thanks doc
That is a good comment. I added a .profile file to my device. This way no edits should be needed in the python sources. However, when someone releases a Python software, the people installing it to their devices should have .profile file also. That might be too much for some people. Well, anyway it makes things lot easier if you use xterm.
Btw… .profile didn’t seem to affect until you boot up the device.
March 13th, 2006 at 3:08 pm
Hi!
Finally I’ve found some time for the N770 during the semester break
The first that I noticed was an error in the files I proposed - after about 30 seconds the application is killed by the system. Did you experience the same problem? I didn’t notice it when writing the files, because the service files a read during the boot sequence (or when restarting the respective system service, what caused the former on my device…). I think the problem is, that the application must register with osso, what is not possible in python since there is an osso-binding (I’ve read a posting from a maemo developer where he announced this, but I can’t find it right now, perhaps it is already available?).
There is a workaround for this, but it is missing the ‘loading …’ message and does not avoid the application to be started multiple times, but I think it’s better than nothing. Sadly I can’t reach my fileserver at the moment, so I can’t post the code right now, but I’ve written a small task manager application that I’ll put online in the evening together with the examples, and I’ll tell you when I’m ready.
Martin
March 13th, 2006 at 3:12 pm
Off topic:
Perhaps it will help me to convince to local admin of the better choice??
I’m currently forced to use the IE, thanks for the nice message on the top of your page
March 13th, 2006 at 3:46 pm
Hi Martin,
Yes.. I’ve noticed that the app doesn’t stay up more than 20 secs or so. Maybe we need to wait for the osso bindings then. I think I saw the same message on maemo lists, but don’t know if there is already a release.
I’m really interested in hearing the workaround you’ve figured out. Also couple other people are interested in the same thing.
Offtopic:
I hope your network admins come to their senses. 
I had already forgot that IE message.
March 13th, 2006 at 5:24 pm
Hi all,
Yes indeed there is other people interested in hearing that workaround
We have currently ran into another problem also, with using images in UI graphics of our program. It seems to be that 770 can’t open image-files. We’ve put folder /images and files in there. When using application installer images doesn’t show in UI. When copying code and image folder directly to mem-card or other folders in 770 and when running program with command ….python2.4 main.py, images show up correctly!
Maybe application installer reduces user rights or something and application cannot access those files, although files are in correct place.
Well this must be more explored, but all installation issues are very interesting to us
March 14th, 2006 at 4:59 am
Hi!
I haven’t found the time to put the promised example application online, but I have found the place where the osso bindings were announced:
http://www.mail-archive.com/maemo-developers@maemo.org/msg02845.html
As long as we don’t have this I think we can’t use osso, so the service file has to be deleted (you have to reboot the N770 before this takes effect). The following .desktop file works fine, but as I said there will be no ‘loading…’ message and you can start the application several times.
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=UITest
Comment=Python UITest
Exec=/home/user/python/uitest.py
Icon=qgn_list_gene_default_app
Terminal=false
Type=Application
X-HildonDesk-ShowInToolbar=true
March 15th, 2006 at 5:46 pm
Ok, thanks Martin.
Lets hope that the libosso bindings will be released sometime soon. And it will also be nice to have the python-dbus modules as well.
March 22nd, 2006 at 9:55 pm
Morical, at PyCon 2006 I attended a “review” of the leading Python IDEs. Eclipse was not highly recommended, primarily because the Python plugin has “gone commercial” and now requires money. ActiveState Komodo is much better, if you’d like to pay for it. WingWare reviewed very well, but I’ve never actually tried it (as it costs money as well).
I’m using Stani’s Python Editor (SPE), which is not *quite* as good as Komodo but excellent by any reasonable standard, including price (it’s free-as-in-GPL). Recommended. http://pythonide.stani.be/
Teemu, thank you *soooo much* for the excellent tutorial. I’m wrapping up my first Python application (a stopwatch with lots of lap timers), having learned Python, GTK+, and Hildon over the past few weeks. You are appreciated!!!
GFR
March 23rd, 2006 at 12:59 am
Hi GFR,
Thanks for the Python editor tips. I’ll check those out too. I have to agree on Eclipse not being too good Python editor.
Nice to hear that my “tutorials” have been of use. Please do publish your own codes also once they are ready. I bet that they will be as good examples or even better than mine.
March 27th, 2006 at 6:17 am
I downloaded the runtime python .deb and installed using the Applications Installer. When I try to import gtk or import hildon, I get an error:
ImportError: /usr/lib/libX11.so.6: undefined symbol: XkbGetU
Do I need to download the .tar.gz file, unpack and install all 3?
Thank you,
Jeffrey Sue
March 27th, 2006 at 11:27 am
Hi Jeffrey,
I assume that you are talking about installing Python to the device not to the PC SDK. Then you only need the pymaemo runtime .deb package. It souldn’t need any other packages to be installed.
Do you get that error with some specific code or have you tried only to import hildon or gtk e.g. from Python console?
March 28th, 2006 at 1:23 pm
Only trying to import hildon or gtk on the console. Haven’t gotten to the code yet.
March 28th, 2006 at 5:52 pm
Hmm.. then it is really strange. It shouldn’t require anything special on the device. Other than the pymaemo runtime I mean. Do you have the latest firmware?
March 29th, 2006 at 6:38 am
I thought I did, the _51 one from late December.
April 3rd, 2006 at 5:16 pm
Hello!
So we’ve gotten bit further lately with our project. Now our software starts to look like something
Lately I’ve been trying to execute OS commands with python commands-module in 770. Everything works great so far, I’ve managed to launch for example 770’s own videoplayer directly from source code..
Now what I’m asking does anyone know stuff about parametrizing command line call to video-player (its ran it with “/usr/bin/video-player”). Does anybody know how to add eg. path to wanted videoclip to that call?
Its nice to see things working out in here too, keep it up Teemu
April 7th, 2006 at 11:17 am
Hi again morical…
Nice to hear you’ve made progress. I think that executing other software will get alot easier once the libosso and dbus modules are ported to pymaemo.
What command are you using to execute the video player? I’m guessing os.popen. You can give parameters to it, but I think the video player is not able to handle those. Or have you tried running something like “/usr/bin/video-player –help” from the terminal?
April 9th, 2006 at 12:05 am
Hi,
I tried to create a ~/.profile file on my 770 but I think I made a big mistake, I remember at one stage I edited the file with Midnight Commander, MaemoPad, Joe, trying several editors, and came up with a file like that :
PATH=/var/lib/install/usr/bin;$PATH
export PATH
Then I rebooted the device and it wouldn’t boot anymore !!! shows nokia logo then nothing more, I had to flash my device. SO BE VERY CAREFUL when editing a file, maybe a bad character was put in it, I don’t know…
April 11th, 2006 at 11:37 pm
Haudi,
I used commands.getoutput(), though it might be bit old-fashioned
By the way, has anyone done any customizing of styles via rc-files? So that one could use own rc-file to define basic style (eg. buttons) for widgets? Or is there some other easy way to customize styles of widget in code with gtk?
I was able to create my own rc-file and use it in maemo, but after I download it to 770 styles don’t work…. both gtk.rc_parse(”filepath”) and gtk.add_default_file(”filepath”) work in maemo but not in 770 (at least not from same path… maybe I have to use those /theme directories and play with them)
June 2nd, 2006 at 8:41 am
I wanted to say thanks to Teemu and the comments here it helped me put together a little app to read MS word docs using antiword. Then display it in a python front end. i created deb file so others can try it out.
http://atlas.kennesaw.edu/~rmw1202/antiwordFE.html
June 2nd, 2006 at 11:09 am
Hi mr.wilson,
Nice to hear that my tutorials have helped you. Nice app you’ve created. I’m gonna check it out.
June 2nd, 2006 at 5:06 pm
Hi, Teemu –
Are you going to get into Eagle (http://www.gustavobarbieri.com.br/eagle/docs/eagle.html )?
June 5th, 2006 at 11:40 am
Hi Robert,
I’ll get into Eagle for sure at some point. I haven’t yet has time to look into it, but it looks very promising.
August 15th, 2006 at 4:47 am
thanks for the tutorials. There has been a lot of talk about the Hildon interface. But I was wondering, are the applets on the home screen also Hildon interfaces, or are they something different?
It would be very cool the be able to make a home screen applet using Python. Is this covered in any part of these tutorials?
I haven’t yet programmed for the 770 at all, but I am familiar with Python on the PC and on Symbian S60.
Nokia made wonderful documentation for python on S60.
But I haven’t seen any documentation on Meamo specific python modules (like for the Hildoninterface). Can anybody provide a link?
August 15th, 2006 at 10:50 am
Hi Bernard,
The applets on the home screen are slightly different from “normal” applications and as far as I know it is not possible to code those totally in python. Maybe some day in the future.
Yes, S60 documentation is really good. However, there is not that extensive documentation on Python for Maemo. This tutorial is really good, but you might have seen it already. Also there is some documentation about the APIs here.
January 8th, 2007 at 3:43 am
hi mate…i’ve just followed this tutorial to create an icon on menu at lybniz, a python app!! i’ve created it but when i try to start it from menu…it says:
loading lybniz…
but after few minutes it disappears a nothing starts….
i can’t undestand why it daesn’t start….could u help me??
thanks…
July 14th, 2007 at 7:23 am
Hi Teemu… I’m so glad that I found you.
I have nobody to ask my problem, neither no idea what the problem is.
I’m making an application using python. It works well on PC.
I made it a deb package, and installed it on nokia 770. When I start the program using commandline, it works perfect. The problem starts when I click the icon to start the problem. Everything’s fine except images. The images don’t show up. Above, morical mentioned sort of same problem as I encountered, so I tried the same way as mentioned. But it doesn’t work for me. Do you have any idea?
July 14th, 2007 at 8:23 am
Hi Shally,
I’m guessing it might have something to do with file access rights. When you launched the application from commandline were you logged in as a root? Otherwise I don’t know what could be causing this. You might wanna ask in the maemo developers mailing list if someone there could help you out. https://maemo.org/mailman/listinfo/maemo-developers