You Are Here:

Community: Developer Discussion Boards

#1 Old Countdown - 2007-02-02, 18:27

Join Date: Jan 2007
Posts: 24
giogiogio
Offline
Registered User
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
Reply With Quote

#2 Old Re: Countdown - 2007-02-02, 19:41

Join Date: Aug 2006
Posts: 78
Location: Calgary,Alberta,Canada
Send a message via MSN to desijatt Send a message via Skype™ to desijatt
desijatt's Avatar
desijatt
Offline
Regular Contributor
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
Reply With Quote

#3 Old Re: Countdown - 2007-02-02, 20:52

Join Date: Jan 2007
Posts: 24
giogiogio
Offline
Registered User
Quote:
I am assuming you are using javaME
what is it??
Reply With Quote

#4 Old Re: Countdown - 2007-02-02, 21:42

Join Date: May 2006
Posts: 622
Location: Oulu, Finland
lfd
Offline
Super Contributor
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
Reply With Quote

#5 Old Re: Countdown - 2007-02-02, 22:05

Join Date: Jan 2007
Posts: 24
giogiogio
Offline
Registered User
THK!!
but..........
Quote:
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.
this i know...i know how to have a backgroud-image...

Quote:
Then draw some text to display the countdown.
my problem is that!...how i could make a countdown??
Last edited by giogiogio : 2007-02-02 at 22:12.
Reply With Quote

#6 Old Re: Countdown - 2007-02-02, 23:27

Join Date: Jan 2007
Posts: 24
giogiogio
Offline
Registered User
in my app i need a countdown.when it is over i need to launch a soud....how?
THK
Reply With Quote

#7 Old Re: Countdown - 2007-02-03, 12:57

Join Date: May 2004
Posts: 524
Location: Tampere, Finland
jethro.fn's Avatar
jethro.fn
Offline
Forum Nokia Champion
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()
This example runs a little slower than once a second, due to the way the timer object is re-scheduled. If you need accurate timekeeping, check the actual elapsed time in counterhandler() using time.time() or by any other means.

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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia