2005-12-28, 15:54
all,
in the script below (i am not a programmer, please excuse my hacked way of doing things), i read in a text (currentstat.txt) file and do some processing on it to display the desired results in a control list, but i fail to get any action when i select an item from the list. right now i have it set to popup a message box when something is selected, but nothing happens. what am i missing here? if you want to run this script, i have also included the currentstat.txt file below - just put it in xbmc/media.
currentstat.txt file
thanks!
in the script below (i am not a programmer, please excuse my hacked way of doing things), i read in a text (currentstat.txt) file and do some processing on it to display the desired results in a control list, but i fail to get any action when i select an item from the list. right now i have it set to popup a message box when something is selected, but nothing happens. what am i missing here? if you want to run this script, i have also included the currentstat.txt file below - just put it in xbmc/media.
Quote:import os, xbmc, xbmcgui, string
import urllib
#from string import split, replace, find
#from xbmcgui import dialogprogress as xbmcguidialogprogress, window as xbmcguiwindow, lock as xbmcguilock, controlimage as xbmcguicontrolimage, controllabel as xbmcguicontrollabel, controlbutton as xbmcguicontrolbutton, controlcheckmark as xbmcguicontrolcheckmark, unlock as xbmcguiunlock, controlimage as xbmcguicontrolimage, controllist as xbmcguicontrollist, dialog as xbmcguidialog
#get actioncodes from keymap.xml
action_previous_menu = 10
action_select_item = 7
root = "f:\\xbmc\\media\\"
websvr = "[url]http://192.168.0.150:80/scott";[/url] # will eventually use this variable instead of explicit definitions below
class myclass(xbmcgui.window):
def (self):
## 0 - 1080i (1920x1080)
## 1 - 720p (1280x720)
## 2 - 480p 4:3 (720x480)
## 3 - 480p 16:9 (720x480)
## 4 - ntsc 4:3 (720x480)
## 5 - ntsc 16:9 (720x480
self.setcoordinateresolution(2)
## self.addcontrol(xbmcgui.controlimage(0,0,720,480, root + "background-x10.png"))
self.lbltitle = xbmcgui.controlfadelabel(75, 53, 500, 90, "font13", "0xffffffff")
self.addcontrol(self.lbltitle)
self.lbltitle.addlabel("xbmc home control")
### make the list
self.statlist = xbmcgui.controllist(200, 95, 310, 360, itemheight=18, space=0)
self.addcontrol(self.statlist)
f = open(root + "currentstat.txt")
### count the number of lines (devices) and stores it in "n"
data = f.read()
n=0
n+=data.count('\n')
f = open(root + "currentstat.txt")
i = 1
while i<=n:
fullline = f.readline()
linetext = string.split(fullline, '|')
c1, c2, c3, c4, c5 = linetext
spaces = 4 - len(c1)
line = c1+spaces*" "+c2
self.statlist.additem(line)
self.setfocus(self.statlist)
i=i+1
def onaction(self, action):
if action == action_previous_menu:
self.close()
def oncontrol(self, control):
if control == self.statlist:
self.message("an item was selected")
titem = self.statlist.getselecteditem()
uitem = self.statlist.getselectedposition()
def message(self, message):
dialog = xbmcgui.dialog()
dialog.ok("command testing dialog", message)
mydisplay = myclass()
mydisplay.domodal()
del mydisplay
currentstat.txt file
Quote:off|living room table lamp|b5|12/25/2005 3:47:20 pm|
on|master bedroom scott's table lamp|b9|5/10/2005 11:27:41 pm|
off|foyer table lamp|b4|12/26/2005 11:26:47 am|
off|front porch exterior lights|b3|12/25/2005 10:47:38 am|
off|master bedroom shea's table lamp|b16|12/26/2005 10:06:41 pm|
on|camera camera 2|c15|12/22/2005 3:04:48 pm|
off|camera camera 3|c16|5/11/2005 11:05:00 pm|
on|great room sony stereo|c1|12/22/2005 3:05:14 pm|
off|front guest room ceiling fan light|g10|12/22/2005 3:05:55 pm|
off|front guest room table lamp|g11|12/22/2005 3:06:03 pm|
on|rear guest bedroom table lamp|g15|5/14/2005 9:05:33 am|
off|garage motion sensor|g7|12:00:00 am|
off|foyer motion sensor|g5|12:00:00 am|
off|kitchen sink light|b6|5/11/2005 2:13:45 pm|
on|great room table lamp|b7|12/27/2005 7:34:00 pm|
off|kitchen notify scott|n1|12/22/2005 3:05:21 pm|
off|web ip address|z1|12/22/2005 3:05:24 pm|
off|camera camera 1|b8|5/11/2005 11:05:00 pm|
on|computer internet access|v2|12/22/2005 3:06:07 pm|
off|emily's bedroom overhead light|b13|12/20/2005 12:04:57 pm|
off|sarah's bedroom overhead light|g14|5/14/2005 9:05:50 am|
off|emily's bedroom table lamp|b14|5/15/2005 1:00:00 am|
on|universal christmas lights|b1|12/27/2005 5:12:00 pm|
on|study floor lamp|b2|12/26/2005 6:42:39 pm|
thanks!