using listitem to run external program?
#1
Is there a way to use ListItem to execute another program? Here's how I'm doing it now:

launchpath = "os.startfile(%s %s%s)" % (x_addon.getSetting('binary_loc'),x_addon.getSetting('ROM_loc'),file_listing[counter])
thumbImage = "%s%s" % (x_addon.getSetting('snap_loc'),snap_listing[counter])
listItem = xbmcgui.ListItem(named_listing[counter],"label2",thumbImage,thumbImage,path=launchpath)

I click on one of them and nothing happens.

Forgive me, I'm new to python coding.
Reply
#2
Anybody?
Reply
#3
I think the standard is to use Popen or os.popen from the subprocess module.

http://docs.python.org/library/subprocess.html
Reply
#4
Is there an example of doing this via listitem?
Reply
#5
Usually in a plugin the listitem executes a function of your script. So a simple plugin might go something like this -

Code:
def myFunction():
        Popen("cmd", shell=True....
        
def addItem():
        #sys.argv[0] should be 'plugin://'+your plugin ID
        u = sys.argv[0] + 'myFunction'
        listitem = xbmcgui.ListItem('MyFunction', iconImage="DefaultFolder.png", thumbnailImage='')        
        xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=listitem)

        
if sys.argv[0] == 'plugin://plugin.program.testing/myFunction':
    myFunction()
else:
    addItem()

xbmcplugin.endOfDirectory(int(sys.argv[1]))
Reply

Logout Mark Read Team Forum Stats Members Help
using listitem to run external program?0