HomePython Page 3 - Mobile Programming in Python using PyS60: UI Controls
The Note Control - 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.
Note is another control implemented as a dialog. It is used to display messages to the user. This is, again, one of the most common controls in the toolkit of PyS60. It can be used to display different messages. These messages can be anything from simple messages, such as information about the size of the current file or critical messages, such as low battery. The note function takes three arguments. They are text, type, and global. Of these, only text is a mandatory argument. The other two are optional. Here are the details.
Text is the message to be shown. It is a Unicode string. For example, to show a message stating that the memory is full, the text argument will be in the following format:
u”Memory is full”
The u at the start indicates that it is a Unicode text.
Now we'll discuss type. As stated earlier, the note function can be used to display different kinds of messages. The kind of message is determined by the value passed for ‘type’ parameter. This parameter can accept the following string values:
Info – is the default value, if no value is passed. When the type is set to info, the message shown will be simple. Hence, the icon will have ‘i’ as a symbol.
Error – to show error messages, one can use this string as the value. If the type is set to ‘error,’ the icon will have ‘e’ as the symbol.
Conf – set the type to ‘conf’ when the message to be shown is related to configuration. An example of configuration is selecting and setting the fonts. Once a font has been set, a message whose type is conf can be shown to the user informing him or her of the name of the new font.
The global argument decides whether the note displayed is global or not. A global note is a note that will be displayed even if the application calling the note function is not in the foreground. The global argument takes an integer value. Any value other than zero is used to make a note or the displayed message global. The default value for this argument is zero. For example, to show a non-global message to the user, the value passed to the global argument will be:
0
For example, to display a global error message stating that the memory is full, the statement will be:
note(u”Memory is full”, error, 1)
That brings us to the end of the third section. The next section will be about building an application using what we've discussed in this article.