Personal tools
Document Actions

Problems tux.event.on_remote_bt

Up to General discussion

Problems tux.event.on_remote_bt

Posted by Francesco Frassinelli at December 25. 2007
In  http://doc.tuxisalive.com/api/tuxapi-0.2.0.html#1.3 I've read an example. Trying it on my Fedpra 8 x86_64, I see:



>>> 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


Re: Problems tux.event.on_remote_bt

Posted by Shrat at December 27. 2007

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

Re: Problems tux.event.on_remote_bt

Posted by Cyriaque Riotte at December 31. 2007
Just got the same error to finally find out that the online documentation seems to be wrong (outdated ?).


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

Re: Problems tux.event.on_remote_bt

Posted by Vianney RIOTTE at January 18. 2008

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")
Powered by Ploneboard
You are here: Home Forum General discussion Problems tux.event.on_remote_bt

Powered by Plone CMS, the Open Source Content Management System