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

Reprocessing the Result - 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.

TABLE OF CONTENTS:
  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
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Next, let us change how the result is processed. To do so, change the code below 


if user_guess is Null:

note(u”You have opted out”)

continue_guess=false

elif user_guess<guess_no:

note(u”Your guess is lesser than the goal”)

elif user_guess>guess_no:

note(u”Your guess is higher than the goal”)

else:

note(u”Congrats for excellent guess”)


to the following


if guess_no < list [user_guess]:

note(u”Your guess is lesser than the goal”)

elif guess_no < list [user_guess]:

note(u”Your guess is higher than the goal”)

elif guess_no == list [user_guess]:

note(u”Congrats for excellent guess”)

else:

note(“Bye”)

continue_guess = false


The index returned by the selection_list() is used by the if condition to get the value selected by the user, from the list. If the index corresponds to the value lesser or greater than the goal value, then a note is displayed telling the user that he/she is either short of the goal or has overshot the goal. Otherwise, the user is congratulated. If the user selected the option to quit, the continue_guess is set to false, thus ending the game. The complete code is as follows:


from appuifw import *


continue_guess=true


while continue_guess:

guess_no=random()

list = [guess-100, guess, guess*200, u”Quit”]

user_guess = selection_list(list)


if guess_no < list [user_guess]:

note(u”Your guess is lesser than the goal”)

elif guess_no < list [user_guess]:

note(u”Your guess is higher than the goal”)

elif guess_no == list [user_guess]:

note(u”Congrats for excellent guess”)

else:

note(“Bye”)

continue_guess = false


That completes our application. This discussion focused on the UI controls. When I next pick up this discussion, I will bring up third party libraries in PyS60. However, I will focus primarily on the graphics module. Till then… 



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

blog comments powered by Disqus
   

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

 



© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap

Dev Shed Tutorial Topics: