Mobile Python: Rapid Prototyping of Applications on the Mobile Platform
by Jürgen Scheible, Ville Tuulos
2.3. Writing a Program in Python for S60
Sidebar 2.1. First PyS60 programWe write a simple program consisting of three lines of code as our first real example. It should do the following:
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