2015-01-15, 06:32
Hello Kodi Devs,
I'm new to add-on development and python in general, hoping someone can help me understand what I'm doing wrong.
I'm attempting to define an action/function with arguments to call based on the listitem selected.
Here's my main add-on code at the moment:
When I run this test script, I get my list, but I don't get 'Test Action' like I'm expecting. Is there an easier way to add actions to a list item?
Additionally, I never see 'Plugin Ended' when i close my add-on, so I'm not sure if that might also be implemented incorrectly.
Any help for a newbie would be greatly appreciated!
I'm new to add-on development and python in general, hoping someone can help me understand what I'm doing wrong.
I'm attempting to define an action/function with arguments to call based on the listitem selected.
Here's my main add-on code at the moment:
Code:
import os, sys
import xbmc
import xbmcgui
import xbmcplugin
addon_handle = int(sys.argv[1])
ACTION_PREVIOUS_MENU = 10
ACTION_SELECT_ITEM = 7
# Main code
class Main(xbmcgui.Window):
def __init__( self, *args, **kwargs ):
items = list()
print 'Plugin Started'
item1= xbmcgui.ListItem('Test 1', '','')
item1.setInfo( "games", { "title": 'Test1', "label": 'Test Label 1'} )
items.append(('Test 1',item1, False))
item2 = xbmcgui.ListItem('Test 2', '','')
item2.setInfo( "games", { "title": 'Test2', "label": 'Test Label 2'} )
items.append(('Test 2',item2, False))
xbmcplugin.addDirectoryItems(addon_handle,items)
xbmcplugin.endOfDirectory(addon_handle)
def onInit(self):
self.window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
self.window.setProperty('MyAddonIsRunning', 'true')
def onAction(self, action):
print 'Test Action'
if action == ACTION_PREVIOUS_MENU:
self.close()
window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
if window.getProperty('MyAddonIsRunning') != 'true':
mydisplay = Main()
mydisplay .doModal()
del mydisplay
window.setProperty('MyAddonIsRunning', 'false')
print 'Plugin Ended'
When I run this test script, I get my list, but I don't get 'Test Action' like I'm expecting. Is there an easier way to add actions to a list item?
Additionally, I never see 'Plugin Ended' when i close my add-on, so I'm not sure if that might also be implemented incorrectly.
Any help for a newbie would be greatly appreciated!