Kodi Community Forum
Moving and resizing a ControlImage - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Moving and resizing a ControlImage (/showthread.php?tid=20492)



- Phunck - 2006-06-13

i have tried setposition, setwidth, setheight... i can not get them to work...

showimage should simply show the image in self.imagefile at the position that is calculated in newpos. if the window doesn't already have a controlimage then i want it to create it first. here's my code:
Quote:def showimage(self):
       picsize = (int(float(self.imagesize[0]*self.asp)*self.zoom), int(float(self.imagesize[1])*self.zoom))
       w=self.getwidth()
       h=self.getheight()

       dw=(w-picsize[0])*.5*self.center[0]
       dh=(h-picsize[1])*.5*self.center[1]

       newpos=(int(dw+(w-picsize[0])/2), int(dh+(h-picsize[1])/2), int(picsize[0]), int(picsize[1]))

       try:
               self.image.setposition(newpos[0],newpos[1])
               self.image.setwidth(newpos[2])
               self.image.setheight(newpos[3])
       except:
               if not (self.image is none):
                       try:
                               self.removecontrol(self.image)
                               self.image=none
                       except:
                               pass
               self.image = xbmcgui.controlimage(newpos[0], newpos[1], newpos[2], newpos[3], self.imagefile)
               self.addcontrol(self.image)

i know it is ugly but it was coded in self defense!!! some times it throws an exception at "self.removecontrol(self.image)" eventhough there clearly is an image on screen (usually if i had pressed one of the triggers).

is this a case where i should use lock/unlock? i have no clue when to use them. in my experience they are highly dangerous if you dont want unhandled exceptions to freeze the xbox.






- Phunck - 2006-06-13

wait a minute i think i have gotten it to work (somewhat),,, no need to answer. sorry about that. posting here made me spot an error.