Community: Blogs

你在这里: You Are Here: Olet tässä: Vous êtes ici: Sie befinden sich hier: Tu sei qui: 現在のページ: Você está aqui: Вы здесь: Usted está aquí:

Tasty Multimedia Journal's Forum Nokia Blog

Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07 June, 2007 01:04

Welcome everybody who is joining us today for a live session about using Python on S60, and in particular about how to use PyS60 for multimedia work. There will be nothing unusual about the way the site works during this session – so ask questions using the “Post Comment” link. Just remember to refresh your page frequently so you see the new content as it goes live.
 
A lot has happened in the few days since Jukka agreed to join us today. Before we start in with questions, let me recap some of the developments:
  • PyS60 1.3.22 was released last Friday. Note that even numbered releases (this one) refer to development releases while odd number releases are the stable ones. According to the release notes, 1.3.22 features improved performance, reduced code size and a better memory allocation mechanism. All users are recommended to upgrade !
    • NEW : experimental device binaries compiled with OMAP 2420 specific optimizations for N93 , N93i , N95 , E90 ( some benchmark results have increased over 300% !!! )  <<my note – sounds perfect for my N93 application>>
    • NEW : Pymalloc memory allocator has been backported from Python 2.5.1 into our codebase and tuned to free memory aggressively
    • NEW : The device binaries for 3rd edition are now compiled with RVCT. This improves both performance and code size.
    • NEW : For the first time now Text primitive work in 3rd ed !
  • A lot of the questions I thought I needed Jukka’s help with, were easily solved with the documentation available on line.
 
With the on-line documentation and about 5 hours of my time, I already have installed the necessary components on my N93, found some sample scripts to capture images and sounds, and run those scripts on the device. Not bad.
 
The resources that got me from there to here include:
 
The canonical source for all things PyS60: Jukka’s clarity and humor show through.
 
The Forum Nokia Wiki already has a great collection of Python How-tos, including code snippets for just about every aspect of my project:
 
 
So let’s recap the questions I had on Friday, and strip the list down to the ones I have not yet been able to answer on my own:
 
  • Overview
    • How do I work in Python?
      • What tools do I need?
        • for PyS60
        • How about working with PyS60 and Carbide.c++?
        • Turns out I don’t need to tackle that any time soon. I had expected to need to drop down into C++ to accomplish some of the multimedia control I wanted to handle. Turns out just about everything I want to do I can do within Python. Cool!
      • What downloads do I need?
      • The main PyS60 wiki includes a link to a detailed installation article which gives you all the info you need and a link to the Sourceforge page where you’ll find the files. For those of you not yet familiar with S60 3rd Edition security modes, make sure you install the “self-signed” package that Jukka already signed. The “unsigned free dev cert” SIS file allows you to sign the installation package yourself with a free developer certificate. If you don’t know what I mean by any of this, then you really don’t want to mess with it now. Just use the self-signed file.
      • Where are the best places to find PyS60 code samples?
      • For my purposes, the FN Wiki already has most of what I need. The PyS60 Wiki includes other sources.
    • How do I package and deploy PyS60?
      • related to Symbian Signing and security model
      • anything else I need to know
      • This is covered in the Wiki. Nothing I need to worry about for some time.
    • How valid is my initial view of PyS60 as being the "perfect" middle starting point?
      • Where, and only where, PyS60 does not provide access to required platform features, I drop down into C++
      • If the UI available in PyS60 is not sufficiently engaging I can wrap it all in a Flash Lite UI wrapper
  • My project specifics
    • multimedia control -- how much control over the camera do I have in PyS60 or can I pass to the user during image capture (for example, in Java, when I use the camera API it disables all user controls e.g. zoom, macro, etc.)
    • How about audio recording?
    • Both the multimedia issues are covered by code snippets in the FN Wiki. I think I’m good here, unless Jukka knows of pitfalls I haven’t seen yet.
    • And some portability issues -- it would be cool if some of the viewer portions of my project were usable on both the N93 and in a desktop environment running a Python interpreter. Can you point me to examples of PyS60 projects designed for portable from mobile to desktop? The marriage of PyS60 and OpenC is an obvious avenue in my mind, but I haven't seen any discussion to date.
    • Database and XML parsing were my primary considerations here, but I now see Python code snippets for db functionality should be straightforward. XML work  may be a bit more involved, but I think with SQL I probably don’t need XML. Maybe.

Comments

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07/06/2007, 18:08

kevin_s2f Good Evening Jukka. Thanks for taking the time to talk PyS60. Your Wiki articles were a great start.

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

jplauril | 07/06/2007, 18:13

Some comments on what seemed like still unanswered parts there:

- You have some control over the settings of the camera such as resolution, type of flash and so on. I think it's best to refer you to the documentation:

http://puzzle.dl.sourceforge.net/sourceforge/pys60/PythonForS60_doc_1_3_22.pdf

Everything you might wish for is unfortunately not covered by the current camera module. These include things like triggering the focusing on cameras that support it, and preparing the camera for taking the photo while the viewfinder is displayed. Every time you say camera.take_photo() it does a full restart of the camera which is suboptimal and causes a large shutter delay. This is something we should address in the future.

- For audio recording we currently have the limitation that setting the sample rate or codec isn't supported, so the fidelity of the recorded sound is hardwired to a level suited mainly for recording speech. Again, something for the future.

- As for portability, these guys have indeed run their Python code on both desktop and S60: http://pdis.hiit.fi/pdis/download/

They have a wrapper that emulates the PyS60 appuifw API over wxWidgets. I haven't used that much, though.

If you try to make something portable between desktop and S60 you should remember that PyS60 is still based on Python 2.2.2 - check that you have Python 2.2 on your desktop as well.

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07/06/2007, 18:18

kevin_s2f OK -- I'll make sure my destkop install is 2.2.2. Speaking of the desktop install, it typically comes with IDLE, right? How useful will that tool be for PyS60 work? You suggest anything better?

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

jplauril | 07/06/2007, 18:27

I'm not really an expert on IDEs. Emacs has been good enough for me for 11 years. I still think that if anyone wants to pursue a career in programming, then they should consider learning Emacs. Sure, there's a long learning curve, but there's also lots of power and the good thing is that you don't need to relearn things every few years. Emacs will outlast most or even all fancy IDEs we have today.

Opinions of course vary. Dedicated IDEs do have a lot of good points, and recently I've moved to Carbide for a lot of my development. With the pydev package it makes a decent Python editor. There are also other Python IDEs available, both commercial and free, but I don't have much to say about them since I haven't tried them properly.

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07/06/2007, 18:31

kevin_s2f I wasn't aware of the pydev package for Carbide. I'll check it out.

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07/06/2007, 18:24

kevin_s2f I just checked out the http://pdis.hiit.fi/pdis/download/ project. Looks like it could be a good fit for integrating the mobile and desktop services I'd love to create. It's worth some digging ...

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07/06/2007, 18:21

kevin_s2f If anyone else is on line, feel free to post your own questions.

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

jplauril | 07/06/2007, 18:34

And of course everyone who's interested is welcome to participate on the fine PyS60 discussion board we have at Forum Nokia: http://discussion.forum.nokia.com/forum/forumdisplay.php?f=102

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

cyke64 | 07/06/2007, 18:34

Hello Jukka and Kevin ,

Best known as cyke64 on the pys60 forum , I want to ask to Jukka when the Pys60 1.4 stable release will be released. The last answer was end of 2006 but it is near end of 2007 now ;)

You made a very good job on this 1.3.22 version (pystones has reached 900 on the N95 and even to 1200 on the N93 !!!

Cyke64

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07/06/2007, 18:41

kevin_s2f Hi Cyke64. For those who haven't met you over on pys60 forum, you want to post a URL to pystones?

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

jplauril | 07/06/2007, 19:04

Hi cyke64 :)

Yes, the 1.4 release is indeed late from the originally anticipated schedule, and this is mainly due to bug fixes taking more time than we thought. We're improving things as fast as we can, and this is also a matter of where we draw the line between fixes we do before the release and fixes we do after the release. If you would consider the latest 1.3.x release already good enough to be called a production release, then you can already use it. 1.3.22 is already quite close to the final 1.4.

"1.4" is really just a name. It's a statement that _we_ think this is now good enough for production use. If you think the latest 1.3.x release is already enough for _your_ use, then no one is stopping you from using it today - and conversely, if someone isn't happy with the quality level in 1.4, they can wait for 1.4.1, 1.4.2 or whatever number of bugfix releases we put out.

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07/06/2007, 18:35

kevin_s2f Thanks again for the time. One last question before I let you start your evening. Over the last week or so I've been impressed, bordering on shocked, at how easy it looks like workign with PyS60 is likely to be. It leaves me with the eerie feeling I'm missing something. What would you say the biggest mistakes a beginner like me are likely to wish they avoided making?

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

jplauril | 07/06/2007, 18:48

These are some of the most common nonobvious mistakes:

- Doing too complex things in UI callbacks. It's actually pretty hard to explain what "too complex" means in this case without explaining the whole Symbian active object framework. The way PyS60 handles active objects currently is suboptimal, and can lead to situations where code that looks like it _could_ work fails due to subtle reasons.

I've been giving a lot of thought to how this could be made easier to handle, and I have some ideas, but they'll happen only after the 1.4 release.

- Not remembering that all strings destined for the screen should be Unicode.

- Using an object that wraps a native resource (files, sockets etc) from a different thread than where it was created. This will crash the interpreter immediately.

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

cyke64 | 07/06/2007, 19:03

Yes , Jukka is right

Using an object that wraps a native resource (files, sockets etc) from a different thread than where it was created. This will crash the interpreter immediately.

In e32 pys60 library you can use e32.is_ui_thread() boolean function (see documentation !)

For pystones testing on Nokia look for this talk on the forum : http://discussion.forum.nokia.com/forum/showthread.php?t=99610

Thanks for this interesting chat !

BR
Cyke64

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07/06/2007, 19:09

kevin_s2f Thanks for the link, and for the threading tip. Dealing with threading in PyS60 is something I know I need to research, because I know threading in Symbian OS is something I don't yet know well enough to predict.

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07/06/2007, 19:04

kevin_s2f Thanks. I'm somewhat familiar with Active Objects, so that warning hits home. I've also noticed the code I'm seeing all uses unicode in strings -- thought that was localization convention, not screen display requirement.

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

janekw_ | 08/06/2007, 10:35

Hi,

I couldn't participate in the discussion yesterday, but I hope these two questions are still relevant:)

1. I think most of the application logic is usually initiated from within user callbacks (keys, softkeys). So how do we do these forbidden "complex things"? In another thread?
2. So there are a few constraints with PyS60, like with the camera module for instance. In such circumstances, is it possible to easily extend the Python code with a C++ module, which would do what is needed?

Thanks for the discussion. It was a great idea!

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 08/06/2007, 19:50

kevin_s2f Jan,

I have not yet worked through the details, but I'll share what I know now and hope that if I'm steering you wrong somebody will step in.

1) It seems as though much of the UI work needs to be done in the main thread -- I don't yet know how or if that impacts usability if the UI function takes time to return. According to the documentation http://puzzle.dl.sourceforge.net/sourceforge/pys60/PythonForS60_doc_1_3_22.pdf
5.1 appuifw: Interface to the S60 GUI framework
The appuifw module offers an interface to the S60 UI application framework. Figure 5.1 provides an
overview of the Python for S60 environment for UI application programming.
Note: The services of this interface may only be used in the context of the main thread, that is, the
initial thread of a UI application script.


Here are some Wiki entries that might help http://wiki.forum.nokia.com/index.php/How_to_handle_keypress_easily and http://wiki.forum.nokia.com/index.php/How_to_add_a_submenu

2) Absolutely. In fact, that's one of the great appeals of Python. Not only can you extend Python using C++ modules, but you can prototype the C++ module in Python and then replace it with the C++ module WITHOUT CHANGING THE REST OF THE PYTHON CODE. At least that's what I've read -- haven't actually done it yet. If you're interested, the language works in the other direction as well -- you can embed a Python interpreter into your C++ code. In know in the desktop and server spaces this technique is often used for field configuration. Check out some code: http://wiki.forum.nokia.com/index.php/How_to_embed_Python_in_Symbian_C%2B%2B

Re: Live Q & A: Using Python for S60 Platform to create multimedia wine tasting journal on Nokia N93

kevin_s2f | 07/06/2007, 19:09

kevin_s2f With that we'll end the live portion of this thread. Thanks again to Jukka for coming, to Cyke64 for participating, and to all those who have been quietly listening. Feel free to continue posting questions to this thread and in the DiBo http://discussion.forum.nokia.com/forum/forumdisplay.php?f=102

Above all, I encourage you to TRY SOMETHING! If you have an idea for something you wish your Nokia phone could do, but are imtimidated by the thought of learning Symbian C++, you owe it to yourself to check out PyS60.

Have a good day.
You must login to post comments. Login
 

Rate This

 
 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditFurlTechnocratiMagnoliaTwitter  Share this page Share this page Invite a friend Invite a friend
E-mail Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us Regional websites: Chinese Japanese © 2008 Nokia 
RDF Facets: qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfnTypeZBlogContentQ qfnZtypeQUqfnTypeZBlogE45ntryQ qfnZtypeQUqfnTypeZCommunityContentQ qfnZtypeQUqfnTypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX