1+ from re import search
12from enigma import eLabel , gRGB
23
34from skin import parseColor
@@ -12,9 +13,10 @@ def __init__(self):
1213 self .colors = {}
1314 self .extendDirection = "right"
1415 self .sidesMargin = 20
16+ self .initialWidth = 0
17+ self .initialXPos = 0
1518
1619 def postWidgetCreate (self , instance ):
17- instance .setNoWrap (True )
1820 self .changed ((self .CHANGED_DEFAULT ,))
1921
2022 def applySkin (self , desktop , parent ):
@@ -31,6 +33,8 @@ def applySkin(self, desktop, parent):
3133 attribs .append ((attrib , value ))
3234 self .skinAttributes = attribs
3335 result = Renderer .applySkin (self , desktop , parent )
36+ self .initialWidth = self .instance .size ().width ()
37+ self .initialXPos = self .instance .position ().x ()
3438 self .changed ((self .CHANGED_DEFAULT ,))
3539 return result
3640
@@ -57,20 +61,22 @@ def changed(self, what):
5761 self .hideLabel ()
5862 return
5963 else :
60- age = int (self .source .text .replace ("+" , "" ))
64+ age = int (search ( r"\d+" , self .source .text .replace ("+" , "" )). group ( ))
6165 if age <= 15 :
6266 age += 3
6367 ageText = str (age )
6468 color = self .colors .get (age , 0x10000000 )
6569 size = self .instance .size ()
6670 pos = self .instance .position ()
71+ self .instance .setNoWrap (True )
6772 self .instance .setText (ageText )
6873 textSize = self .instance .calculateSize ()
74+ self .instance .setNoWrap (False )
6975 newWidth = textSize .width () + self .sidesMargin
70- if newWidth < size . width () :
71- newWidth = size . width ()
76+ if newWidth < self . initialWidth :
77+ newWidth = self . initialWidth
7278 if self .extendDirection == "left" :
73- rightEdgePos = pos . x () + size . width ()
79+ rightEdgePos = self . initialXPos + self . initialWidth
7480 self .move (rightEdgePos - newWidth , pos .y ())
7581 if self .extendDirection != "none" :
7682 self .resize (newWidth , size .height ())
0 commit comments