launch plugin/script from home menu button
#1
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
Reply
#2
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())
Reply
#3
bump
Reply
#4
You want a script not a plugin. That error is due to you attempting to run a plugin as a script.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#5
jmarshall Wrote:You want a script not a plugin. That error is due to you attempting to run a plugin as a script.

well you mentioning that distinction probably puts me on the right track, as a small nudge in the right direction

but aside from names, it appears XBMC doesn't exactly care about the difference between something called a script and something called a plugin

I've seen on the wiki that there is SUPPOSED to be a distinction, but everything (emphasis on everything) on that wiki is out of date with questionable relevance

is there an updated guide to writing scripts?
Reply
#6
start by writing a script that works as a normal script, the launch from home menu is another problem.
Reply
#7
ppic Wrote:start by writing a script that works as a normal script, the launch from home menu is another problem.

well this addon is just supposed to return a folder........... like plugins do.


I am using the runscript command in the <onclick>, is there a way to run a plugin using the ActivateWindow command? I couldn't figure it out if there was
Reply
#8
ActivateWindow(window_you_want,plugin://addon_id)
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#9
jmarshall Wrote:ActivateWindow(window_you_want,plugin://addon_id)

got it, thanks.
Reply

Logout Mark Read Team Forum Stats Members Help
launch plugin/script from home menu button0