Change/remove controlimage?
#1
hi there,
i am new to python and i want to make a lil' script.
i've got two problems with the thumbnail viewer (controlimage):
1.) the controlimage can't show selfmade pictures (png/jpg). if i give it "background.png" it shows the picture properly. does it have to be a special format or smthng?!
2.) the thumbnail has to change when i select another item.. how do i do that? i tried to give it a name and delete the controlimage for adding a new one.. that did not work.
thanks,
dderichs
Reply
#2
'background.png' only works because that file is in the skin directory.

if you want your own file you need to give a full path to the image like 'q:\scripts\flower.png'


here is how you switch images
Quote:if self.image != null (or something):
self.removecontrol(self.image)
del self.image
self.image = controlimage(...)
self.addcontrol(self.image)
Reply
#3
thx for the answer, it was very helpful Wink
now here's another question:
the image is refreshing with an oncontrol (with up + down buttons)
Quote: # down = 4
if action == action_button_down:
self.newsel()
# up = 3
if action == action_button_up:
self.newsel()
how do i realize that?
i tried it with the key-codes 111 and 112. the first usage of a trigger works, but after this the image does not refresh anymore (even not with the dpad)

thanks
Reply
#4
im not entirely sure what you are doing with the the action_up and down stuff but i think you are trying to get the selection back from a listcontrol to do the image?...

anyway i sometimes had a problem with changing images really fast in that sometimes i wouldnt finish downloading an image before i changed it and the image would get stuck somehow... it doesnt sound like it is related though since you said it only works the first time... it sounds like you arent cleaning something up somewhere... look after you set the image to make sure the program isnt locking up (check the output <white button> to see if you are getting an error)

if you are trying to capture moves in a list control you might also want to do stuff on these...
Quote:#define action_scroll_up 111
#define action_scroll_down 112
#define action_page_up 5
#define action_page_down 6
Reply
#5
i've got a listcontrol with some items in it...
now i want to update a thumbnail everytime i use the dpad or the triggers.
everytime i use the dpad, it calls newsel(), which updates a controllabel and the thumbnail:
Quote:action_button_down = 4
action_button_up = 3
[...]
if action == action_button_down:
self.newsel()
if action == action_button_up:
self.newsel()
[...]
def newsel(self):
sleep(0.01)
self.infolabel.setlabel(self.getselitem())

self.removecontrol(self.infoimage)
del self.infoimage
self.infoimage = xbmcgui.controlimage(75,125,100,100,[...])
self.addcontrol(self.infoimage)
this is working very fine.
now i want to do _exactly_ the same thing with the triggers.
but if i call newsel() when using them, the script f*cks up.
Quote:action_trigger_l = 111
action_trigger_r = 112
[...]
if action == action_trigger_l:
self.newsel()
if action == action_trigger_r:
self.newsel()
i don't understand the reason and i hope you can help me
Reply
#6
hmm the triggers sendsend messages pretty quickly... you might want to try something that keeps track of time when you use the triggers so you are only updating the image every so often..

it might be related to the sleep i suppose... im not sure if the calls to python will block so there may be weird threading issues with the triggers... does it work without the sleep at all?

also i seem to remember having problems with the triggers giving the action before the new control is selected but i could of been wrong about that....
Reply
#7
when i remove the sleep() it f*cks up even with the dpad.
sometimes its updating before the new item is selected -> the old one is shown in the controllabel and controlimage.
Reply
#8
(dderichs @ april 12 2005,14:22 Wrote:sometimes its updating before the new item is selected -> the old one is shown in the controllabel and controlimage.
yeah i remember something like that happening to me at some point... never did think about doing a sleep(), although it doesnt sound like it works completely. i think i got frustrated and ended up doing the navigation manually (which did end up working)... but with that i had to fake a listcontrol which was a lot of trouble...

given that issue it sounds like a threading thing.. at this point i would try messing around with threads and timers.

im mostly just thinking outloud though so if someone could come in with something more authoritative that would be great.
Reply

Logout Mark Read Team Forum Stats Members Help
Change/remove controlimage?0