Skip to Content
Mobile Python: Rapid Prototyping of Applications on the Mobile Platform
book

Mobile Python: Rapid Prototyping of Applications on the Mobile Platform

by Jürgen Scheible, Ville Tuulos
December 2007
Intermediate to advanced
348 pages
8h 5m
English
Wiley
Content preview from Mobile Python: Rapid Prototyping of Applications on the Mobile Platform

2.3. Writing a Program in Python for S60

Sidebar 2.1. First PyS60 program

We write a simple program consisting of three lines of code as our first real example. It should do the following:

  1. Display a text input field on the screen; the instruction in the text field should say 'Type your name' (see Figure 2.11(a)).

  2. Display a popup note stating 'Greetings from:' followed by whatever the user typed into the text input field (see Figure 2.11(b)).

Figure 2-11. Our first Python script example: (a) a text input field and (b) a popup note

The code to do this is as follows:

import appuifw
name = appuifw.query(u"Type your name:", "text")
appuifw.note(u"Hello world! Greetings from: " + str(name), "info")

In the first line of code, we import the appuifw module, which handles user interface elements such as text input fields and popup notes.

In the second line of code, we create a single-field dialog (Figure 2.11(a)) using the query() function of the appuifw module with two parameters: label and type. For the first parameter, label, we put the text u "Type your name:". The u is required because the phone understands only text declared as Unicode and the quotation marks are needed because the label parameter must be given as a string. As the second parameter, type, we put "text", to declare the input field as a text dialog. Other possible types are "number", "date", "time", "query" and "

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Hands-On Music Generation with Magenta

Hands-On Music Generation with Magenta

Alexandre DuBreuil
Coding iPhone Apps for Kids, 1st Edition

Coding iPhone Apps for Kids, 1st Edition

Gloria Winquist, Matt McCarthy
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 9780470515051Purchase book