1 from ConditionalWidget import ConditionalWidget
2 from GUIComponent import GUIComponent
4 from enigma import ePixmap, eTimer
6 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
8 from skin import loadPixmap
10 class Pixmap(GUIComponent):
13 class PixmapConditional(ConditionalWidget, Pixmap):
14 def __init__(self, withTimer = True):
15 ConditionalWidget.__init__(self)
18 class MovingPixmap(Pixmap):
24 # TODO: get real values
30 self.moveTimer = eTimer()
31 self.moveTimer.callback.append(self.doMove)
33 def clearPath(self, repeated = False):
40 self.repeated = repeated
42 def addMovePoint(self, x, y, time = 20):
43 self.path.append((x, y, time))
45 def moveTo(self, x, y, time = 20):
47 self.addMovePoint(x, y, time)
49 def startMoving(self):
51 self.time = self.path[self.currDest][2]
52 self.stepX = (self.path[self.currDest][0] - self.x) / float(self.time)
53 self.stepY = (self.path[self.currDest][1] - self.y) / float(self.time)
56 self.moveTimer.start(100)
67 self.move(int(self.x), int(self.y))
68 except: # moving not possible... widget not there any more... stop moving
75 if (self.currDest >= len(self.path)): # end of path
84 class MultiPixmap(Pixmap):
89 def applySkin(self, desktop, screen):
90 if self.skinAttributes is not None:
91 skin_path_prefix = getattr(screen, "skin_path", path)
94 for (attrib, value) in self.skinAttributes:
95 if attrib == "pixmaps":
96 pixmaps = value.split(',')
98 self.pixmaps.append(loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, p, path_prefix=skin_path_prefix), desktop) )
100 pixmap = resolveFilename(SCOPE_SKIN_IMAGE, pixmaps[0], path_prefix=skin_path_prefix)
101 elif attrib == "pixmap":
102 pixmap = resolveFilename(SCOPE_SKIN_IMAGE, value, path_prefix=skin_path_prefix)
104 attribs.append((attrib,value))
106 attribs.append(("pixmap", pixmap))
107 self.skinAttributes = attribs
108 return GUIComponent.applySkin(self, desktop, screen)
110 def setPixmapNum(self, x):
112 if len(self.pixmaps) > x:
113 self.instance.setPixmap(self.pixmaps[x])
115 print "setPixmapNum(%d) failed! defined pixmaps:" %(x), self.pixmaps