Posts: 28
Joined: Jan 2011
Reputation:
0
Hello,
I am trying to use RunScript to launch a script that I am writing. Just with testing it on various other scripts, some work, and some don't.
Right now I am following the XBMC Addon Develop Guide, nothing special. But I want to launch my script from a custom home menu button too. Right now I get:
thisPlugin = int(sys.argv[1])
IndexError: list index out of range
Well , okay. What should that sys.argv equal instead? Is there a similar way to do "thisPlugin" ? I see a lot of other plugins use "self" but I am not sure what that represents yet
Any insight would be appreciated
Posts: 28
Joined: Jan 2011
Reputation:
0
This is from the addon development tutorial, I need this same thing to run from after I press the custom home menu button
1 """
2 XBMC Addon Developer's Guide
3 Example 1 - The basic plugin structure
4 Demonstrates creating a static list
5
6 NB This is done using functions - you could use classes
7
8 Author: Ashley Kitson
9 """
10
11 # Step 1 - load in xbmc core support and setup the environment
12 import xbmcplugin
13 import xbmcgui
14 import sys
15
16 # magic; id of this plugin's instance - cast to integer
17 thisPlugin = int(sys.argv[1])
18
19 # Step 2 - create the support functions (or classes)
20
21 def createListing():
22 """
23 Creates a listing that XBMC can display as a directory listing
24
25 @return list
26 """
27 listing = []
28 listing.append('The first item')
29 listing.append('The second item')
30 listing.append('The third item')
31 listing.append('The fourth item')
32 return listing
33
34
35 def sendToXbmc(listing):
36 """
37 Sends a listing to XBMC for display as a directory listing
38 Plugins always result in a listing
39
40 @param list listing
41 @return void
42 """
43 #access global plugin id
44 global thisPlugin
45
46 # send each item to xbmc
47 for item in listing:
48 listItem = xbmcgui.ListItem(item)
49 xbmcplugin.addDirectoryItem(thisPlugin,'',listItem)
50
51 # tell xbmc we have finished creating the directory listing
52 xbmcplugin.endOfDirectory(thisPlugin)
53
54 # Step 3 - run the program
55 sendToXbmc(createListing())
Posts: 26,215
Joined: Oct 2003
Reputation:
187
You want a script not a plugin. That error is due to you attempting to run a plugin as a script.
Posts: 2,710
Joined: Feb 2009
Reputation:
12
ppic
Skilled Python Coder
Posts: 2,710
start by writing a script that works as a normal script, the launch from home menu is another problem.
Posts: 26,215
Joined: Oct 2003
Reputation:
187
ActivateWindow(window_you_want,plugin://addon_id)