X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/cd621fe499141885e5a0d8b4e42a0f8a7f41a9ac..54bd4123728628a6f77bad2584b70d1353a91666:/components.py diff --git a/components.py b/components.py index 52c94606..ac4262ea 100644 --- a/components.py +++ b/components.py @@ -27,12 +27,18 @@ class GUISkin: def createGUIScreen(self, parent): for (name, val) in self.items(): self.data[name] = { } - val.GUIcreate(self.data[name], parent, None) + if isinstance(val, GUIComponent): + val.GUIcreate(self.data[name], parent, None) def deleteGUIScreen(self): for (name, val) in self.items(): - w = self.data[name]["instance"] - val.GUIdelete(self.data[name]) + if isinstance(val, GUIComponent): + w = self.data[name]["instance"] + val.GUIdelete(self.data[name]) + try: + val.fix() + except: + pass del self.data[name] # note: you'll probably run into this assert. if this happens, don't panic! @@ -60,7 +66,7 @@ class GUISkin: # way of having refcounted objects. So it must be in python.) # # It could be possible that you're calling deleteGUIscreen trough a call of - # a PSignal. For example, you could try to call session.close() in response + # a PSignal. For example, you could try to call screen.doClose() in response # to a Button::click. This will fail. (It wouldn't work anyway, as you would # remove a dialog while running it. It never worked - enigma1 just set a # per-mainloop variable on eWidget::close() to leave the exec()...) @@ -174,18 +180,24 @@ class Clock(HTMLComponent, GUIComponent, VariableText): return self.getText() class Button(HTMLComponent, GUIComponent, VariableText): - def __init__(self, text=""): + def __init__(self, text="", onClick = [ ]): GUIComponent.__init__(self) VariableText.__init__(self) self.setText(text) - self.onClick = [ ] + self.onClick = onClick def push(self): for x in self.onClick: x() return 0 -# html: + def disable(self): + pass + + def enable(self): + pass + +# html: def produceHTML(self): return "\n" @@ -198,6 +210,21 @@ class Button(HTMLComponent, GUIComponent, VariableText): def GUIdeleteInstance(self, g): g.selected.get().remove(self.push) +class Label(HTMLComponent, GUIComponent, VariableText): + def __init__(self, text=""): + GUIComponent.__init__(self) + VariableText.__init__(self) + self.setText(text) + +# html: + def produceHTML(self): + return self.getText() + +# GUI: + def GUIcreateInstance(self, priv, parent, skindata): + g = eLabel(parent) + return g + class Header(HTMLComponent, GUIComponent, VariableText): def __init__(self, message): @@ -224,23 +251,85 @@ class VolumeBar(HTMLComponent, GUIComponent, VariableValue): g.setRange(0, 100) return g -class MenuList(HTMLComponent, GUIComponent): +# a general purpose progress bar +class ProgressBar(HTMLComponent, GUIComponent, VariableValue): def __init__(self): GUIComponent.__init__(self) + VariableValue.__init__(self) + + def GUIcreateInstance(self, priv, parent, skindata): + g = eSlider(parent) + g.setRange(0, 100) + return g + +class MenuList(HTMLComponent, GUIComponent): + def __init__(self, list): + GUIComponent.__init__(self) + self.l = eListboxPythonStringContent() + self.l.setList(list) def getCurrent(self): -# return self.l.getCurrentSelection() - return "none" + return self.l.getCurrentSelection() + + def GUIcreateInstance(self, priv, parent, skindata): + g = eListbox(parent) + g.setContent(self.l) + return g + def GUIdeleteInstance(self, g): + g.setContent(None) + +class ServiceList(HTMLComponent, GUIComponent): + def __init__(self): + GUIComponent.__init__(self) + self.l = eListboxServiceContent() + def GUIcreateInstance(self, priv, parent, skindata): g = eListbox(parent) - # BIG BIG HACK. :( we have to ensure that the eListboxPythonStringContent doesn't get destroyed. - # we really have to take a look at the GC stuff - l = eListboxPythonStringContent() - l.setList(["Test Object 1", "Item #2", "Item #3", "nun kommt eine Zahl:", 15, "Bla fasel", "lulabla"]) - g.setContent(l) + g.setContent(self.l) return g def GUIdeleteInstance(self, g): g.setContent(None) - #del self.l + + def setRoot(self, root): + self.l.setRoot(root) + +class ServiceScan: + + Idle = 1 + Running = 2 + Done = 3 + Error = 4 + + def scanStatusChanged(self): + if self.state == self.Running: + self.progressbar.setValue(self.scan.getProgress()) + if self.scan.isDone(): + self.state = self.Done + else: + self.text.setText("scan in progress - %d %% done!\n%d services found!" % (self.scan.getProgress(), self.scan.getNumServices())) + + if self.state == self.Done: + self.text.setText("scan done!") + + if self.state == self.Error: + self.text.setText("ERROR - failed to scan!") + + def __init__(self, progressbar, text): + self.progressbar = progressbar + self.text = text + self.scan = eComponentScan() + if self.scan.start(): + self.state = self.Error + else: + self.state = self.Running + self.scan.statusChanged.get().append(self.scanStatusChanged) + self.scanStatusChanged() + + def isDone(self): + return self.state == self.Done + + def fix(self): + self.scan.statusChanged.get().remove(self.scanStatusChanged) + \ No newline at end of file