Ok, ich versuche es mal einfach zu gestalten
Ich weiß, dass der Code sehr kompliziert ist und auch eine ganze Weile gebraucht habe, um da halbwegs durchzusehen
Hiermit wird der originale TimeshiftState-Screen in self.pvrStateDialog per instantiateDialog im InfoBarPVRState festgelegt:
Der Aufruf erfolgt in der InfoBar.py mit InfoBarTimeshiftState.__init__(self)
http://git.opendreambox.org/?p…3586c061fa5abb305a7d6#l70
from Screens.PVRState import PVRState, TimeshiftState
class InfoBarPVRState:
def __init__(self, screen=PVRState, force_show = False):
print "=== InfoBarPVRState_init"
self.onPlayStateChanged.append(self.__playStateChanged)
self.pvrStateDialog = self.session.instantiateDialog(screen)
self.pvrStateDialog.neverAnimate()
self.onShow.append(self._mayShow)
self.onHide.append(self.pvrStateDialog.hide)
self.onClose.append(self.__delPvrState)
self.force_show = force_show
def __delPvrState(self):
self.session.deleteDialog(self.pvrStateDialog)
self.pvrStateDialog = None
def _mayShow(self):
if self.execing and self.seekstate != self.SEEK_STATE_PLAY:
self.pvrStateDialog.show()
print "=== InfoBarPVRState_myshow"
def __playStateChanged(self, state):
playstateString = state[3]
self.pvrStateDialog["state"].setText(playstateString)
# if we return into "PLAY" state, ensure that the dialog gets hidden if there will be no infobar displayed
# also hide if service stopped and returning into MovieList
if not config.usage.show_infobar_on_skip.value and self.seekstate in (self.SEEK_STATE_PLAY, self.SEEK_STATE_STOP) and not self.force_show:
self.pvrStateDialog.hide()
else:
self._mayShow()
class InfoBarTimeshiftState(InfoBarPVRState):
def __init__(self):
InfoBarPVRState.__init__(self, screen=TimeshiftState, force_show = True)
self.__hideTimer = eTimer()
self.__hideTimer_conn = self.__hideTimer.timeout.connect(self.__hideTimeshiftState)
print "=== InfoBarTimeShiftState_init"
def _mayShow(self):
if self.execing and self.timeshift_enabled:
self.pvrStateDialog.show()
print "=== InfoBarTimeShiftState_mayshow"
if self.seekstate == self.SEEK_STATE_PLAY and not self.shown:
self.__hideTimer.start(5*1000, True)
def __hideTimeshiftState(self):
print "=== InfoBarTimeShiftState_hide"
self.pvrStateDialog.hide()
Alles anzeigen
Im PTS ersetzte ich dann den self.pvrStateDialog mit folgender Zeile und übergebe dabei meinen neuen TimeshiftState-Screen:
self.pvrStateDialog = self.session.instantiateDialog(PTSStandardTimeshiftState, self)
Screen-Code:
class PTSStandardTimeshiftState(Screen):
skin = """
<screen position="center,75" size="940,60" zPosition="2" backgroundColor="background" flags="wfNoBorder">
<widget name="state" position="10,3" size="100,30" font="Regular;23" halign="center" backgroundColor="background"/>
<widget source="session.CurrentService" render="Label" position="115,5" size="80,30" font="Regular;23" halign="right" foregroundColor="white" backgroundColor="background">
<convert type="ServicePosition">Position</convert>
</widget>
<eLabel text="/" position="198,5" size="10,30" font="Regular;23" halign="center" foregroundColor="white" backgroundColor="background"/>
<widget source="session.CurrentService" render="Label" position="212,5" size="80,30" font="Regular;23" halign="left" foregroundColor="white" backgroundColor="background">
<convert type="ServicePosition">Length</convert>
</widget>
<widget name="eventname" position="300,5" size="500,30" font="Regular;23" halign="center" backgroundColor="background" />
<widget source="Service" render="Label" position="840,5" size="100,30" font="Regular;23" halign="left" foregroundColor="white" backgroundColor="background">
<convert type="PTSTimeshiftPosition">Remaining,Negate</convert>
</widget>
<eLabel position="20,43" size="900,3" backgroundColor="grey" />
<widget source="Service" render="Progress" position="20,40" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/PermanentTimeshift/images/progress_pts_20.png" size="900,8" transparent="1" zPosition="2" >
<convert type="PTSTimeshiftPosition">Position</convert>
</widget>
<widget source="Service" render="Progress" position="20,40" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/PermanentTimeshift/images/progress_live_20.png" size="900,8" transparent="1" zPosition="1" >
<convert type="PTSLiveEventPosition">Position</convert>
</widget>
</screen>"""
def __init__(self, session, parent):
Screen.__init__(self, session, parent)
self.skinName = "PTSStandardTimeshiftState"
self["state"] = Label(text="")
self["eventname"] = Label(text="")
self["Service"] = PTSCurrentService(session.nav, parent)
Alles anzeigen
Das funktioniert soweit, nur dass dabei irgendwie die Kopplung mit der normalen Infobar verloren geht und dabei insbesondere das Ausblenden der PTS-Infobar händisch im PTS-Code nachkorrigiert werden muss.
Nun dachte ich, man kann diese obigen Classes anpassen und in der PTS-Infobar-Class neu mit __init__ staren und dabei einfach meinen angepassten TimeshiftState-Screen übergeben.
class InfoBar(InfoBarOrg):
def __init__(self, session):
print "=== pts InfoBar__init__"
InfoBarOrg.__init__(self, session)
InfoBarOrg.instance = self
InfoBarTimeshiftState.__init__(self, self)
Die beiden obigen Classes hab ich dann versucht anzupassen, damit das mit dem parent klappt:
from Screens.PVRState import PVRState
class InfoBarPVRState:
def __init__(self, screen=PVRState, force_show = False, parent = None):
print "=== InfoBarPVRState_init"
self.onPlayStateChanged.append(self.__playStateChanged)
self.pvrStateDialog = self.session.instantiateDialog(screen, parent)
self.pvrStateDialog.neverAnimate()
self.onShow.append(self._mayShow)
self.onHide.append(self.pvrStateDialog.hide)
self.onClose.append(self.__delPvrState)
self.force_show = force_show
def __delPvrState(self):
self.session.deleteDialog(self.pvrStateDialog)
self.pvrStateDialog = None
def _mayShow(self):
if self.execing and self.seekstate != self.SEEK_STATE_PLAY:
self.pvrStateDialog.show()
print "=== InfoBarPVRState_myshow"
def __playStateChanged(self, state):
playstateString = state[3]
self.pvrStateDialog["state"].setText(playstateString)
# if we return into "PLAY" state, ensure that the dialog gets hidden if there will be no infobar displayed
# also hide if service stopped and returning into MovieList
if not config.usage.show_infobar_on_skip.value and self.seekstate in (self.SEEK_STATE_PLAY, self.SEEK_STATE_STOP) and not self.force_show:
self.pvrStateDialog.hide()
else:
self._mayShow()
class InfoBarTimeshiftState(InfoBarPVRState):
def __init__(self, parent):
InfoBarPVRState.__init__(self, screen=TimeshiftState, force_show = True, parent = parent)
self.__hideTimer = eTimer()
self.__hideTimer_conn = self.__hideTimer.timeout.connect(self.__hideTimeshiftState)
print "=== InfoBarTimeShiftState_init"
def _mayShow(self):
if self.execing and self.timeshift_enabled:
self.pvrStateDialog.show()
print "=== InfoBarTimeShiftState_mayshow"
if self.seekstate == self.SEEK_STATE_PLAY and not self.shown:
self.__hideTimer.start(5*1000, True)
def __hideTimeshiftState(self):
print "=== InfoBarTimeShiftState_hide"
self.pvrStateDialog.hide()
class TimeshiftState(Screen):
skin = """
<screen position="center,75" size="940,60" zPosition="2" backgroundColor="background" flags="wfNoBorder">
<widget name="state" position="10,3" size="100,30" font="Regular;23" halign="center" backgroundColor="background"/>
<widget source="session.CurrentService" render="Label" position="115,5" size="80,30" font="Regular;23" halign="right" foregroundColor="white" backgroundColor="background">
<convert type="ServicePosition">Position</convert>
</widget>
<eLabel text="/" position="198,5" size="10,30" font="Regular;23" halign="center" foregroundColor="white" backgroundColor="background"/>
<widget source="session.CurrentService" render="Label" position="212,5" size="80,30" font="Regular;23" halign="left" foregroundColor="white" backgroundColor="background">
<convert type="ServicePosition">Length</convert>
</widget>
<widget name="eventname" position="300,5" size="500,30" font="Regular;23" halign="center" backgroundColor="background" />
<widget source="Service" render="Label" position="840,5" size="100,30" font="Regular;23" halign="left" foregroundColor="white" backgroundColor="background">
<convert type="PTSTimeshiftPosition">Remaining,Negate</convert>
</widget>
<eLabel position="20,43" size="900,3" backgroundColor="grey" />
<widget source="Service" render="Progress" position="20,40" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/PermanentTimeshift/images/progress_pts_20.png" size="900,8" transparent="1" zPosition="2" >
<convert type="PTSTimeshiftPosition">Position</convert>
</widget>
<widget source="Service" render="Progress" position="20,40" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/PermanentTimeshift/images/progress_live_20.png" size="900,8" transparent="1" zPosition="1" >
<convert type="PTSLiveEventPosition">Position</convert>
</widget>
</screen>"""
def __init__(self, session, parent):
Screen.__init__(self, session, parent)
self.skinName = "PTSStandardTimeshiftState"
self["state"] = Label(text="")
self["eventname"] = Label(text="")
self["Service"] = PTSCurrentService(session.nav, parent)
Alles anzeigen
Bei InfoBarTimeshiftState.__init__(self, self) erhalte ich dann immer diesen Fehler "AttributeError: class InfoBarTimeshiftState has no attribute '_InfoBar__init'".
Der Fehler kommt aber auch, wenn ich die originale InfoBarTimeshiftState-Class mit InfoBarTimeshiftState.__init__(self) aufrufen will.
Also scheint der (Denk)Fehler nicht nur im angepassten Code zu liegen.