January 27th, 2005, 10:33 AM
I am Stuck, help requested.
I have written a script that goes out to a directory of playlists, then makes a list of them you can choose from, after a choice is made it will load the playlist, shuffle the songs and then play it. What I NEED it to do is run exactly like it is but if no selection is made within 10 seconds, I want it to load shuffle and play the default playlist. I simply cant figure out how to do this. Any help would be appreciated.
import os, xbmc, xbmcgui
try: Emulating = xbmcgui.Emulating
except: Emulating = False
#get actioncodes from keymap.xml
ACTION_PREVIOUS_MENU = 10
if Emulating: xbmcgui.Window.__init__(self)
# Make the List
self.list = xbmcgui.ControlList(290, 300, 150, 150)
#Define Playlist Directory here
path = 'c:\\albums\\playlists\\'
list = os.listdir(path)
intcount = len(list)
for a in list :
def onAction(self, action):
if action == ACTION_PREVIOUS_MENU:
def onControl(self, control):
if control == self.list:
item = self.list.getSelectedItem()
path1 = 'c:\\albums\\playlists\\'
mydisplay = MyClass()
January 27th, 2005, 05:41 PM
Please read the sticky thread at the top of this forum regarding how to as a Question. Since Python uses indentation to define code blocks this is particularly important when posting code .
Anyway, normally if you wanted to wait 10 seconds before performing an action you would use the time modules sleep() function. See the link below for more information on this:
January 27th, 2005, 11:02 PM
I dont want to wait 10 seconds before I do something even I can figure out the sleep(10). What I want is for my script to run, if you make a choice, great, it does its thing. If you dont make a choice, it choses the default selection and does its thing.
I thank you for taking the time to reply, is there anyway I can send you a copy of this code so you could look at it. I have posted similar requests EVERYWHERE I can think of, either this cant be done (which I HIGHLY doubt) or I am just an unlucky sap who isnt gonna get any help.
Originally Posted by netytan
January 28th, 2005, 03:59 AM
Less haste more speed.
I scanned what docs I could find on Python and xbmc(gui) and none of them show you how to handle events which would be the best way (with a timer event).
I looked at your code (not easy at all without indentations!), the xbmcgui doc
and I find it looks similar to wxWindows.
This (untested) code might work:
No guarantees (I don't have an Xbox)
mydisplay = MyClass()
for x in range(10):
mydisplay.getHeight() #to see if the dialog is still there
#any other default action code
My guess is that some combination of show/close is what you want. Failing that write to the authors of the GUI and ask them how to set up a timer
Last edited by Grim Archon; January 28th, 2005 at 04:05 AM.
January 28th, 2005, 10:58 AM
Thank You for the Reply
I have asked for help in no less than 6 different places, your the first person to send back any code at all, Thank You. If you want to take a look at the script in its proper format email me at email@example.com and I will send it over to you. I am going to try and figure out who did the xbmcgui for python and get ahold of them next, thanks to your input.