PDA

View Full Version : Add script to button on the remote


josephk
2007-04-08, 14:32
Hi:

I am new on this.
I want to make a script that when I am in the video navigation section, where I see all the videos I have in my remote pc, I could to read an xml I have in the system.
The idea is, I am viewing the videos, so I push the 3 button in the remote and then the script search in the xml I have and give me an alert with all the data I want from this xml.
Can anyone help me how to control that button action in the remote to take effect the script?

I suppose that there are many examples I can look at for this, but I can not find it.

Thanks so much.

Nuka1195
2007-04-08, 16:57
<MyVideoLibrary>
<remote>
<three>XBMC.RunScript(q:\scripts\Scriptfolder\default.py)</three>
</remote>
</MyVideoLibrary>



find all the <MyVideo*> sections then in the <remote> section place <three>XBMC.RunScript(q:\scripts\Scriptfolder\default.py)</three>

josephk
2007-04-08, 20:55
Thenks so much, it works perfect, but I have another problem now, how do I get the label of the item that was selected when I click the three button?
I try with something like:

self.theList.getSelectedItem(lstPos).label()

but it does not work.
I suppose it is a stupid question but I did not find the solution

jmarshall
2007-04-09, 01:24
First you'll have to get the current window, then get the list control on that window (probably via getting the current control).

If that all works, then you should be able to use the code you have.

I'm not sure how reliable the code is at accessing controls in windows that were not created by python.

Nuka1195 et al probably know way more about it than me.

Cheers,
Jonathan

Nuka1195
2007-04-09, 01:39
I never tried it, but i would try xbmc.getInfoLabel("ListItem.Label")

josephk
2007-04-09, 04:13
Ok, it works perfect, thanks so much.

Now the final problem, I have this script:

import xbmc, xbmcgui
import os
try: Emulating = xbmcgui.Emulating
except: Emulating = False
#get actioncodes from keymap.xml
ACTION_PREVIOUS_MENU = 10
ACTION_SELECT_ITEM = 7
ACTION_PARENT_DIR = 9
class MyClass(xbmcgui.Window):
def __init__(self):
if Emulating: xbmcgui.Window.__init__(self)
self.addControl(xbmcgui.ControlImage(0,0,720,480, "C:\\scripts\\Plugin\\background.gif"))
self.strActionInfo = xbmcgui.ControlLabel(100, 200, 200, 200, "", "font13", "0xFFFF00FF")
self.addControl(self.strActionInfo)
self.strActionInfo.setLabel("Push BACK to quit, A to display text and B to erase it")
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
self.close()
if action == ACTION_SELECT_ITEM:
f = open ( "C:\\scripts\\Plugin\\testBinary.txt", "w" )
f.write ( "There is no spoon." )
f.close()
if action == ACTION_PARENT_DIR:
self.removeControl(self.strAction)
mydisplay = MyClass()
mydisplay.doModal()
del mydisplay


I think it just go to another window and if I click A then create a file in C:\\scripts\\Plugin
I try to write a file with the three rows of code to create the file and works perfect, but in this code it does not work, I get the error:

03:07:39 M: 35401728 INFO: f.write("just a probe")

03:07:39 M: 35401728 INFO: NameError

03:07:39 M: 35401728 INFO: :

03:07:39 M: 35401728 INFO: name 'f' is not defined

What am I doing wrong?

Thanks so much

Nuka1195
2007-04-09, 06:18
probably an indentation error, try posting the code again with indentation, but wrap it with the code blocks, not quote blocks.

josephk
2007-04-10, 09:59
You are right, the indentation was the problem.
Thanks so much.