From df7d9f3578c68b22c95ab9daa23bd0fa168f6d11 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 24 Feb 2006 14:14:57 +0000 Subject: [PATCH] generic show/hide support for GUIComponents --- lib/python/Components/ConditionalWidget.py | 38 ++++++++-------------- lib/python/Components/GUIComponent.py | 18 +++++++++- lib/python/Components/GUISkin.py | 2 -- lib/python/Components/Input.py | 6 ---- lib/python/Components/Label.py | 6 ---- lib/python/Screens/EpgSelection.py | 24 +++++++------- lib/python/Screens/HelpMenu.py | 12 ++++--- 7 files changed, 50 insertions(+), 56 deletions(-) diff --git a/lib/python/Components/ConditionalWidget.py b/lib/python/Components/ConditionalWidget.py index b77d8658..07d59e02 100644 --- a/lib/python/Components/ConditionalWidget.py +++ b/lib/python/Components/ConditionalWidget.py @@ -4,17 +4,13 @@ from GUIComponent import * from enigma import * class Widget(GUIComponent): - - SHOWN = 0 - HIDDEN = 1 - def __init__(self): GUIComponent.__init__(self) - self.instance = None - self.state = self.SHOWN def GUIcreate(self, parent): self.instance = self.createWidget(parent) + if self.state == self.HIDDEN: + self.instance.hide() def GUIdelete(self): self.removeWidget(self.instance) @@ -23,14 +19,6 @@ class Widget(GUIComponent): def removeWidget(self, w): pass - def showWidget(self): - self.state = self.SHOWN - self.instance.show() - - def hideWidget(self): - self.state = self.HIDDEN - self.instance.hide() - def move(self, x, y): self.instance.move(ePoint(int(x), int(y))) @@ -50,11 +38,11 @@ class ConditionalWidget(Widget): def activateCondition(self, condition): if (condition): - if (self.state == self.HIDDEN): - self.showWidget() + if self.state == self.HIDDEN: + self.show() else: - if (self.state == self.SHOWN): - self.hideWidget() + if self.state == self.SHOWN: + self.hide() def update(self): if (self.conditionalFunction != None): @@ -83,10 +71,10 @@ class BlinkingWidget(Widget): def blink(self): if self.blinking == True: - if (self.state == self.SHOWN): - self.hideWidget() - elif (self.state == self.HIDDEN): - self.showWidget() + if self.state == self.SHOWN: + self.hide() + elif self.state == self.HIDDEN: + self.show() def startBlinking(self): self.blinking = True @@ -94,8 +82,8 @@ class BlinkingWidget(Widget): def stopBlinking(self): self.blinking = False - if (self.state == self.SHOWN): - self.hideWidget() + if self.state == self.SHOWN: + self.hide() self.timer.stop() class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget): @@ -109,4 +97,4 @@ class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget): self.startBlinking() else: if self.blinking: # we are blinking - self.stopBlinking() \ No newline at end of file + self.stopBlinking() diff --git a/lib/python/Components/GUIComponent.py b/lib/python/Components/GUIComponent.py index 5483d181..1476ba83 100644 --- a/lib/python/Components/GUIComponent.py +++ b/lib/python/Components/GUIComponent.py @@ -5,8 +5,12 @@ from enigma import ePoint class GUIComponent: """ GUI component """ + SHOWN = 0 + HIDDEN = 1 + def __init__(self): - pass + self.state = self.SHOWN + self.instance = None def execBegin(self): pass @@ -16,7 +20,19 @@ class GUIComponent: # this works only with normal widgets - if you don't have self.instance, override this. def applySkin(self, desktop): + if self.state == self.HIDDEN: + self.instance.hide() skin.applyAllAttributes(self.instance, desktop, self.skinAttributes) def move(self, x, y): self.instance.move(ePoint(int(x), int(y))) + + def show(self): + self.state = self.SHOWN + if self.instance is not None: + self.instance.show() + + def hide(self): + self.state = self.HIDDEN + if self.instance is not None: + self.instance.hide() diff --git a/lib/python/Components/GUISkin.py b/lib/python/Components/GUISkin.py index cf8e1894..f97dd8bd 100644 --- a/lib/python/Components/GUISkin.py +++ b/lib/python/Components/GUISkin.py @@ -25,8 +25,6 @@ class GUISkin: else: f() - - def deleteGUIScreen(self): for (name, val) in self.items(): if isinstance(val, GUIComponent): diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py index a0252e46..f1a17d90 100644 --- a/lib/python/Components/Input.py +++ b/lib/python/Components/Input.py @@ -78,9 +78,3 @@ class Input(HTMLComponent, GUIComponent, VariableText): if self.type == self.PIN or self.type == self.NUMBER: self.right() self.update() - - def show(self): - self.instance.show() - - def hide(self): - self.instance.hide() \ No newline at end of file diff --git a/lib/python/Components/Label.py b/lib/python/Components/Label.py index 129180f4..5ad071ab 100644 --- a/lib/python/Components/Label.py +++ b/lib/python/Components/Label.py @@ -24,12 +24,6 @@ class Label(HTMLComponent, GUIComponent, VariableText): s = self.instance.calculateSize() return (s.width(), s.height()) - def show(self): - self.instance.show() - - def hide(self): - self.instance.hide() - class LabelConditional(Label, ConditionalWidget): def __init__(self, text = "", withTimer = True): ConditionalWidget.__init__(self, withTimer = withTimer) diff --git a/lib/python/Screens/EpgSelection.py b/lib/python/Screens/EpgSelection.py index c8db81b3..378e0d89 100644 --- a/lib/python/Screens/EpgSelection.py +++ b/lib/python/Screens/EpgSelection.py @@ -155,25 +155,25 @@ class EPGSelection(Screen): def applyButtonState(self, state): if state == 1: - self["now_button_sel"].showWidget() - self["now_button"].hideWidget() + self["now_button_sel"].show() + self["now_button"].hide() else: - self["now_button"].showWidget() - self["now_button_sel"].hideWidget() + self["now_button"].show() + self["now_button_sel"].hide() if state == 2: - self["next_button_sel"].showWidget() - self["next_button"].hideWidget() + self["next_button_sel"].show() + self["next_button"].hide() else: - self["next_button"].showWidget() - self["next_button_sel"].hideWidget() + self["next_button"].show() + self["next_button_sel"].hide() if state == 3: - self["more_button_sel"].showWidget() - self["more_button"].hideWidget() + self["more_button_sel"].show() + self["more_button"].hide() else: - self["more_button"].showWidget() - self["more_button_sel"].hideWidget() + self["more_button"].show() + self["more_button_sel"].hide() def onSelectionChanged(self): if self.type == EPG_TYPE_MULTI: diff --git a/lib/python/Screens/HelpMenu.py b/lib/python/Screens/HelpMenu.py index e947ac91..06f0cfab 100644 --- a/lib/python/Screens/HelpMenu.py +++ b/lib/python/Screens/HelpMenu.py @@ -31,12 +31,14 @@ class HelpMenu(Screen): def SelectionChanged(self): selection = self["list"].getCurrent()[3] + arrow = self["arrowup"] + if selection is None: - self["arrowup"].instance.hide() + arrow.hide() else: - self["arrowup"].moveTo(selection[1], selection[2], 1) - self["arrowup"].startMoving() - self["arrowup"].instance.show() + arrow.moveTo(selection[1], selection[2], 1) + arrow.startMoving() + arrow.show() class HelpableScreen: def __init__(self): @@ -44,8 +46,10 @@ class HelpableScreen: { "displayHelp": self.showHelp, }) + def showHelp(self): self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList) + def callHelpAction(self, *args): if len(args): (actionmap, context, action) = args -- 2.30.2