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

Text - Python

In an earlier article I wrote, the topic of discussion covered the basic UI controls that PyS60 provides. These controls are useful when the solution to be developed is simple in terms of interaction. However, if a scenario presents itself where interaction becomes complex, then the basic controls would not suffice. Keep reading to learn about the advanced controls you'll need to deal with these kinds of issues.

  1. Mobile Programming using PyS60: Advanced UI Controls
  2. Text
  3. PyS60 in Real World
  4. Reprocessing the Result
By: A.P.Rajshekhar
Rating: starstarstarstarstar / 3
December 29, 2008

print this article



Text provides text editor with almost all of the text formatting functionalities. The control is provided by Text type. Unlike selection or multi-selection lists, text is a type. The functionalities provided by the text type are categorized as either attributes or methods. More precisely, since the text is a type, the functionalities are exposed either as a attribute or a method. 

The most commonly used attributes of Text include the following:  

  • color: Defines the color of the text. The valid values are all the colors supported by graphic models ingraphicsmodule. 
  • font: Determines the font family of the text. It can be set using the supported Unicode name.
  • style: Affects the style of the text. The valid values for this attribute are defined as flags. The valid flags are provided byappuifwmodule. Some of the commonly used flags are:
    • STYLE_BOLD – Makes the text bold.
    • STYLE_UNDERLINE – Underlines a displayed text.
    • STYLE_ITALIC – Makes the text italic.

For example, to use a Text type with LatinPlain12 as the font value with bold text, the statements would be:

t = appuifw.Text()

t.font = u"LatinPlain12" # sets font to Latin Plain 12

t.style = appuifw.STYLE_BOLD

As mentioned above, the Text type provides various methods to perform common operations on the text held by the editor. The most common methods are:

  • add() : Accepts a Unicode string as an argument. This method appends a text to the existing text. It can also be used to insert the passed argument at current cursor position. 
  • set() : Just like the add() method, it accepts a Unicode string as an argument. Specifically, it sets the passed Unicode string as an argument. It replaces any text that may be present in the editor. 
  • delete() : Accepts two arguments, position and length, and deletes characters in the editor for the given length, editor starting from the position passed as argument.


For example, to set a string having the value “This is a text” as the text in the editor, the statement is

t.set(u”This is a text”)

This brings us to the end of this section. In the next section, the guessing game application that was developed in the previous article (linked to at the beginning of this one) will be enhanced using a single selection list.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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: