Looping GUI updates: self.After() vs time.sleep()
#1
hey,
i'm having trouble with a looping gui program. it's not updating the screen and i believe the problem is that i've ported a tkinter python gui over to the xbmcui.

for the most part, things are working. actually, for anyone else building tkinter versions of xbox scripts to test on the pc, i highly recommend using the canvas object for everything. you can use the same coordinates and widths for items, and the create_image function is very similar in structure to the xbmcgui controlimage.

ehh. way off track. my point is, where i used self.after() for all my delayed calls in the tkinter script, there is no self.after() in xbmcgui (apparently). anyone have any suggested workarounds that would keep the script running while delaying a function call? time.sleep(), of course, delays the whole script.

also, if there's not an easy way to script in a self.after(), does anyone know a function call to force an xbmcgui update?

thanks for any help.
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply
#2
okay, i think i've got this resolved (i'm having problems making the gui itself draw my images, so i can't particularly test this, but it seems like a useful pair of functions so i'm sharing it...in case it does work (shrug).

you have to import "thread" and "time" which are both python built-ins.

Quote:def after(self, wait, func):   # passed time in msecs, function to call.
   # run the function in a new thread, so it won't hang main script
   thread.start_new_thread(self.delay, (wait, func))

def delay(self, wait, func):
   time.sleep(wait * .001)    # convert msecs into secs and delay this thread
   func()                          # call the function passed as a parameter

and example function call would be:
Quote:    self.after(5000, self.close)

to delay the self.close() function long enough for all my other loops to end (which keeps xbmc from hanging on close).
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply

Logout Mark Read Team Forum Stats Members Help
Looping GUI updates: self.After() vs time.sleep()0