onAction() method
#1
hi,

i've finally started tinkering with python. thanks to all the helpful people on this and the xbox-scene forums, it was pretty easy to take it up.

a small question though: how do i check against an 'action' sent to my window? i know i can change the onaction method, but i would like to check for a specific action while i'm in a loop of my own (and not via the domodal() method). ie:

Quote:window.show()
while (action<>action_shutdown):
output('still running!')
window.close
del window

what should the while statement look like?
Reply
#2
if you want to receive events, then you need to implement the window.onaction() method to receive those events. have you tried implementing the onaction() method and storing the action in a variable that you can check in your mainloop after window.show()? i'm thinking of something like this:

Quote:isshutdown = 0

class window( xbmcgui.window ):
def onaction( action ):
if action == 10: # previous menu
isshutdown = 1

win = window()
win.show()
while isshutdown == 0:
# do whatever you need to do
win.close()

i haven't tested this code but onaction() is how your window receives events.
Reply
#3
great, thanks!

i thought the actions were only received during a modall() call, but apparently they're not. why on earth i didn't simply try before, i don't know Smile
Reply

Logout Mark Read Team Forum Stats Members Help
onAction() method0