2013-06-06, 07:27
So i have a basic knowledge of python programming and i have been reading xbmc scripting documentation but i am having difficulty grasping essential basic information required to develop some simple scripts. For example i would like to eventualy create a script to display information i have stored in sql database(but for now i will probably start out with displaying information i have stored in file on my local computer) but it seems i am not allowed to define labels using string variables and i am confused how to go about adding functionality to my script using my own variables and functions. I have seen other scripts calling other .py scripts inside the defualt.py script but this confuses me and seems overly complicated and can i not simply add functionality in the init function? for example.
again this is very basic example of what i am trying to do and i assume i am going about this completely the wrong way. and would be extremely grateful if someone could help point me in the right direction.
Code:
import xbmc, xbmcgui
#get actioncodes from https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
ACTION_PREVIOUS_MENU = 10
class MyClass(xbmcgui.Window):
def __init__(self):
myList[]
#read file storing relevent data to list
#other functionality
myList.append('hello world')
self.strActionInfo = xbmcgui.ControlLabel(250, 80, 200, 200, '', 'font14', '0xFFBBBBFF')
self.addControl(self.strActionInfo)
self.strActionInfo.setLabel('Push BACK to quit')
self.list = xbmcgui.ControlList(200, 150, 300, 400)
self.addControl(self.list)
self.list.addItem(myList.pop())
self.setFocus(self.list)
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
self.close()
def onControl(self, control):
if control == self.list:
item = self.list.getSelectedItem()
self.message('You selected : ' + item.getLabel())
def message(self, message):
dialog = xbmcgui.Dialog()
dialog.ok(" My message title", message)
mydisplay = MyClass()
mydisplay.doModal()
del mydisplay
again this is very basic example of what i am trying to do and i assume i am going about this completely the wrong way. and would be extremely grateful if someone could help point me in the right direction.