Running code "on script startup"
#1
ok, this might be a tricky one, but i hope someone can help.

normally when you create an object of a class then do domodal() you get what you want. however, i am trying to make some cool animations that will run on startup and on end. the end animation is a piece of cake, however getting code to run on the beginning isn't easy. the problem is that the code isn't drawn onto the screen using domodal(), but it will show if i use windowclassname.show(self) in the loop (the latter being much slower for a reason). i know it's hard to grasp what i'm trying to do, but please have a look at the script below and you'll likely understand...

http://enderw.emutalk.net/xbmclyrics.py_

thanks in advance.
xbmcscripts.com administrator
Reply
#2
hi
hehe
i tryed to understand, but i don't know if it is because of my english or because you are not clear...

what is your request ? what you did works and you find it too slow ?
Reply
#3
if you look at the animations you'll notice that the latter is much more smooth than the first. this is due to that i am using show() on the first and domodal() on the second. what i want to do is run code right after start when i am using domodal(). i have yet to figure out a way of doing this in a easily...
xbmcscripts.com administrator
Reply
#4
i'm offereing this to see if you think this is a really bad way to do this. i like your animation.

get rid of:
class start(xbmcgui.windowdialog):

get rid of this in class overlay:

       ###start animation###
       start = start()
       #start.domodal()
       for x in range(80):
           start.animation_start(x)
           start.show(self)
       start.close()
       ####
change in class overlay the starting position so it's off screen (something like this):

self.panel = xbmcgui.controlimage(int(self.xratio*(158+(animation*562))),int(self.yratio*25),int(self.x

ratio*520),int(self.yratio*500), self.home+'lyricspanel.png')

in class overlay get rid of:
   def animation_start(self, pct):

add this to def run(self) (i added it first):
       if animation == 1:
           pos = 80
           for x in range(80):
                 time.sleep(0.01)
                 self.overlay.animation_close(pos)
                 pos -= 1

also the textbox or list shows up early, maybe set it to visible(false) then visible(true) after the start animation. too tired to mess with it.

i think that's all i changed. it seem to work, not sure if it's a really bad way of doing it. but maybe it will give you a better idea. if the above doesn't work for you i can post the changed script that does.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#5
ah, so that's what it's called! i was looking for something that would execute on start, but i didn't know of the run function. thus i tried to find another way around and got all that other mess. thanks a lot, will try it out soon!
xbmcscripts.com administrator
Reply
#6
seems like i misunderstood a bit at first. however, i got it working now, thanks a lot! will release version with animations soon...
xbmcscripts.com administrator
Reply
#7
cool
sounds good !

i knew the def run() for thread. is that working for any class ?? or maybe i have misunderstood... sorry if it is the case...
Reply
#8
nope, that's the same thing i misunderstood. he meant to place it in the thread (afaik). at least that worked. what would be nice was a built in function in xbmc that would execute, say onstart() in any class made from xbmcgui similar to onaction() and oncontrol(). that way you wouldn't need a seperate thread to do this (in my case i had another thread so not much extra work on my part).

i have uploaded the updated version to xbmcscripts.com . i hope you enjoy it and please report any bugs.

thanks again nuka! Smile
xbmcscripts.com administrator
Reply
#9
works smooth, i like it.

yes i meant put it in the threaded class.

one thing would be neat, if you wanted to. is slide the list and textbox in with the panel and maybe even slide with each song change.

do you mind if i "borrow" your code. i like the idea of a button on the home page that slides out the status of kaid running on my router.

thank you for the credit. wasn't necessary, but is appreciated. Smile
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#10
sliding the text and such in is sorta harder to do due to different loading times from the site etc. i don't think i will bother sliding the textbox in either, got "better" things to do right now Wink

of course you can use the code yourself, go ahead.
xbmcscripts.com administrator
Reply

Logout Mark Read Team Forum Stats Members Help
Running code "on script startup"0