Skip to content

Commit 3858906

Browse files
committed
[RatingIconLabel]
* fix color * improve posioning
1 parent 7a4a6f3 commit 3858906

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

lib/python/Components/Converter/EventInfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def getEPGData():
468468
rating = country[self.RATING_NORMAL].get(age, country[self.RATING_DEFAULT](age))
469469
ageText = rating[self.RATING_SHORT].strip().replace("+", "")
470470
color = rating[self.RATING_COLOR]
471-
return f"{ageText};{hex(color)}"
471+
return f"{ageText};#{color:08X}"
472472
case self.RUNNING_STATUS:
473473
if event.getPdcPil():
474474
result = {

lib/python/Components/Renderer/RatingIconLabel.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from re import search
12
from enigma import eLabel, gRGB
23

34
from 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

Comments
 (0)