Home arrow Python arrow Page 2 - Mobile Programming in Python using PyS60: UI Controls

UI Controls: Query and Notes - Python

In this discussion I will focus on the basics of using a UI library provided by PyS60. The first section will focus on the types of controls. The second and third sections will be about two basic controls – query and note. In the fourth section, a simple application will be developed that uses the controls discussed in the second and third sections. That’s the agenda for this discussion.

TABLE OF CONTENTS:
  1. Mobile Programming in Python using PyS60: UI Controls
  2. UI Controls: Query and Notes
  3. The Note Control
  4. PyS60 in Real World
By: A.P.Rajshekhar
Rating: starstarstarstarstar / 2
February 27, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Query and Notes controls are the most commonly used of all the controls. They are used to take input and display messages. Here are the details:

Query is a dialog type. It is used to gather input from the user. It presents a single line text box with a label to the user. Since query is a dialog, it is also implemented as a function. There are three parameters to the function. They are label, type, and initial value. The first two are mandatory parameters, whereas the third is optional. Here are the details:

The label is the question or prompt that is shown to the user when the dialog box is displayed. The value for this argument is a Unicode string. For example, to show “Enter name” as the prompt, one will use the following as the value of the argument:

U”Enter name”

Type can be compared with the standard input dialog box that is common on the PC. Since it is a dialog, it can be of different dialog types. The type is decided by the type parameter of the query function. The different types are:

  • Text – is a simple text. The text is of Unicode type.
  • Code 
  • Number – in this case, the input box will accept only numbers and not decimals.
  • Date – the input is just a date. 
  • Time – to take time as input, the type needs to be set to time.
  • Float – to accept only decimals, this type can be used.


All of these are string values. For example, to set the type to number, the value passed will be:

number’

The initial value is an optional parameter. It sets the initial value shown to the user. However, for the type float, setting this value does not have any effect. For text fields (i.e. the type having the value of either ‘text’ or ‘code’), the value for this argument is Unicode. If the type is ‘number,’ the value that can be passed is a numeric value only. If the type is date, then the initial value will be seconds, since an epoch is rounded to the nearest local midnight. For example, to set the initial value to 3, the value passed will be:

3

The return value of the query is the value provided by the user and the type of the input box. Therefore, to display a query with “Enter any number between 1 and 9” as a message, with number as the only acceptable data type and 0 as the initial value, the statement will be:

guess=query(u“Enter any number between 1 and 9”, ‘number’,0)

This is the end of the second section. In the next section, we will discuss the note control.



 
 
>>> More Python Articles          >>> More By A.P.Rajshekhar
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: