| Reply | « Previous Thread | Next Thread » |
|
how could i have a countdown in my app?
i would have a countdown in my app,and show it in the screen(over an image)??there is a function?or how i could? THK |
|
I am assuming you are using javaME. If thats he case, you could display it on the screen using either a Form or Canvas. You would have to read the api for that.
Rupinder Deol |
|
Quote:
|
|
Hi giogiogio,
You can use the canvas object for that. Check the doc (PythonForS60_doc_1_3_17.pdf) to understand how it works. In your redraw_callback function you need to, first draw the image you want to by using the blit function . That would make it the " background " image. Then draw some text to display the countdown. LFD Devices: Nokia E61 3rd Edition - pys60 1.4.0 Tips and modules: http://www.lfdm.net/thesis |
|
THK!!
but.......... Quote:
Quote:
Last edited by giogiogio : 2007-02-02 at 22:12.
|
|
in my app i need a countdown.when it is over i need to launch a soud....how?
THK |
|
You can use e32.Ao_timer() for creating a countdown. Module audio can be used to play a sound. Here's an example you can study:
Code:
#!/usr/bin/env python
# -*- coding: iso8859-1 -*-
# countdown.py - Counts down seconds from 100, then plays a sound
# by Jussi Ylänen
#
# v1.00 2007-02-03
# Initial version
import e32
import appuifw
import audio
# Load a sound file.
sound = audio.Sound.open("E:\\Sounds\\Digital\\explosion.wav")
# Create a timer and a callback function for it.
countervalue = 100
counter = e32.Ao_timer()
def counterhandler():
global counter, countervalue, listbox, sound
# Update counter value.
countervalue -= 1
listbox.set_list([u"%03d" % countervalue])
# Comment out, if you don't want the light to stay on during countdown.
e32.reset_inactivity()
if countervalue > 0:
# Re-schedule a new timer event.
counter.after(1, counterhandler)
else:
# Counter reached 0, play sound and delete the timer object.
e32.ao_yield() # Redraw before starting sound. Looks better that way.
sound.play()
counter = None
# Create a lock for exit handling. Normally the program just waits for the lock.
exitlock = e32.Ao_lock()
def exithandler():
exitlock.signal()
appuifw.app.exit_key_handler = exithandler
# Add a single menu item: "Exit".
appuifw.app.menu = [(u"Exit", exithandler)]
# Create a listbox UI.
def selecthandler():
# Do nothing on select.
pass
listbox = appuifw.Listbox([u"%03d" % countervalue], selecthandler)
appuifw.app.body = listbox
e32.ao_yield() # Force a screen redraw.
# Schedule an initial timer event after one second. From then on,
# the callback will re-schedule the timer once a second.
counter.after(1, counterhandler)
# Main loop: do nothing, except wait for program exit (set in exithandler()).
exitlock.wait()
# Stop and delete a running timer.
if counter:
counter.cancel()
del counter
# Stop sound and delete the object.
sound.stop()
sound.close()
del sound
# Request a graceful program exit.
appuifw.app.set_exit()
You need to provide your own sound ("E:\Sound\Digital\explosion.wav"). The example uses listbox UI because it is the simplest. You can of course use text or canvas UIs as well. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| How to create countdown timer display in the nokia 7610? | Hector_D | Mobile Java General | 0 | 2005-01-19 03:02 |