Problems tux.event.on_remote_bt
Up to General discussion
>>> def my_function(key):
... print remote_bt_name[key]
...
>>> tux.event.on_remote_bt=my_function
>>> Exception in thread _loop_tux_data_dispatching:
Traceback (most recent call last):
File "/usr/lib64/python2.5/threading.py", line 460, in __bootstrap
self.run()
File "/usr/lib64/python2.5/threading.py", line 440, in run
self.__target(*self.__args, **self.__kwargs)
File "/opt/tuxdroid/api/python/tuxapi_class.py", line 381, in _loop_tux_data_dispatching
self._dispatch_data_main(data)
File "/opt/tuxdroid/api/python/tuxapi_class.py", line 396, in _dispatch_data_main
self._dispatch_data_from_tux(data)
File "/opt/tuxdroid/api/python/tuxapi_class.py", line 460, in _dispatch_data_from_tux
if self.event.on_remote_bt[ord(data[5])]!=None:
TypeError: 'function' object is unsubscriptable
I think you can't use it with print.
I use this syntax for my script :
tux.event.set_on_remote_bt(K_UP, dossier_sup)
dossier_sup is the name of the function.
Hope it helps
Actually either use:
tux.event.on_remote=my_function
or
tux.event.on_remote_bt[K_PLAYPAUSE]=my_function
As described in tuxapi_class.py:
Example of associating a function to a remote event:
>>> def my_function(key):
>>> print "Button %s is pressed"%remote_bt_name[key]
>>> tux.event.on_remote=my_function
Example of associating a function to a specific remote event:
>>> def play_pause():
>>> tux.sys.shell("audacious --play-pause")
>>> tux.event.on_remote_bt[K_PLAYPAUSE]=play_pause
I'm using this one too :
[...]
tux.event.on_bt_pushed=CheckCommand
tux.event.on_remote=CheckCommandRemote
[...]
def CheckCommand():
print "Button" # %s is pressed"%remote_bt_name[key]
def CheckCommandRemote(key):
print "Button %s is pressed"%remote_bt_name[key]
if ( remote_bt_name[key] == "K_OK" ):
tux.tts.speak( "OK pressed")