| Reply | « Previous Thread | Next Thread » |
|
Hi Guys,
I'm trying to write a couple of simple bits of code, but it's not clicking. Trying to set it up so that when you hit the exit key, the program asks you for confirmation before quitting, and if you select no, it drops back to the program. However the exit key doesn't seem to want this. What am I doing wrong? Code:
import appuifw, e32
def quit_game():
appuifw.note(u"You Exit")
app_lock.signal()
def return_game():
appuifw.note(u"Return to game")
appuifw.app.exit_key_handler = appuifw.app.menu = [(u"Yes", quit_game), (u"No", return_game)]
app_lock = e32.Ao_lock()
app_lock.wait()
|
|
Join Date: Nov 2007
Posts: 319
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Offline
Forum Nokia Champion
|
|
|
Quote:
appuifw.app.exit_key_handler expects a function, not a list. ![]() Marcelo Marcelo Barros Nokia E71, N800, N95 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
|
Gah!
Well I went and modified the code for a function! And no luck, it just quits straight up Code:
def confirm_quit():
appuifw.app.menu = [(u"Yes", quit_game), (u"No", return_game)]
def quit_game():
appuifw.note(u"You Exit")
app_lock.signal()
def return_game():
appuifw.note(u"Return to game")
print (u"Running Exit Menu")
appuifw.app.exit_key_handler = confirm_quit()
app_lock = e32.Ao_lock()
app_lock.wait()
|
|
Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Rafael T.
Offline
Forum Nokia Champion
|
|
Hi sonictail,
Easy thing to do Try this: Code:
import appuifw
def quit_game():
c = appuifw.query(u"Do you really want to quit?", "query")
if c:
appuifw.note(u"You Exit")
app_lock.signal()
else:
appuifw.note(u"Return to game")
pass
appuifw.app.exit_key_handler = quit_game
app_lock = e32.Ao_lock()
app_lock.wait()
Hope it helps, Rafael. |
|
Thanks! That worked a treat
![]() I'm having a lot of problems with designing simplified code, it's causing me massive issues I really appreciate the assist. |
|
Join Date: Feb 2008
Posts: 2,543
Location: Bhavnagar, Gujarat, India
gaba88
Online
Forum Nokia Champion
|
|
|
Quote:
you are always welcome in this wonderful forum to ask for any sort of assistance you require. ![]() Moreover if you are a newbie do have a look at my tutorials. Enjoy Pythoning Gaba88 ![]() Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Join Date: Nov 2007
Posts: 319
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Offline
Forum Nokia Champion
|
|
Sorry, sonictail, I just answered a quick and short response imagining you was only with some of that distractions that happens to us frequently. Fortunately, we have a lot of generous persons at this dibo ! ;-)
Marcelo Barros Nokia E71, N800, N95 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
|
Quote:
Seriously, it did help as it appears to have been the final piece everything clicking, I can write python now!Quote:
|
|
Quote:
We have made the site available at http://pys60.uuuq.com Alternatively you can also have a look at http://ck.umraliya.googlepages.com Regards, |
|
Join Date: Feb 2008
Posts: 2,543
Location: Bhavnagar, Gujarat, India
gaba88
Online
Forum Nokia Champion
|
|
|
Quote:
i guess the problem is solved now and the website is working fine. Are you still getting that sort of notification in chrome?? Enjoy Pythoning Gaba88 Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Exit key does not work for standalone app. | richard_a | Python | 6 | 2008-07-16 06:34 |
| right soft key to exit on full-screen canvas | Larry101 | Mobile Java General | 5 | 2008-02-21 12:44 |
| why my does not exit on N73 when i push exit soft key? | byronlilu | Mobile Java General | 2 | 2007-06-28 22:29 |
| N70 Reset bug | sebboB | General Discussion | 2 | 2005-12-29 00:09 |
| UNDESIRED Exit command key. | tektronic | Mobile Java General | 4 | 2005-05-13 19:27 |