From 13b7a9b397f36ca3195aad3702feb3db4cbb2f3e Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Tue, 18 Jan 2005 06:56:52 +0000 Subject: [PATCH 1/1] slightly better example of using the signals (eButton::selected -> Button::onClick -> Screen "closed!") --- components.py | 12 ++++++++++-- mytest.py | 16 +++++++++++++++- screens.py | 1 - 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/components.py b/components.py index 315ae44c..7c793231 100644 --- a/components.py +++ b/components.py @@ -97,12 +97,20 @@ class Clock(HTMLComponent, GUIComponent, VariableText): return self.getText() class Button(HTMLComponent, GUIComponent, VariableText): - onClick = {} - def __init__(self, text=""): GUIComponent.__init__(self) VariableText.__init__(self) self.setText(text) + self.onClick = [ ] + + def clicked(self): + for x in self.onClick: + x() + return 0 + + def GUIcreate(self, priv, parent, skindata): + GUIComponent.GUIcreate(self, priv,parent, skindata) + priv["instance"].selected.get().append(self.clicked) def click(self): for x in self.onClick: diff --git a/mytest.py b/mytest.py index e5dd7e96..53a398ed 100644 --- a/mytest.py +++ b/mytest.py @@ -108,6 +108,8 @@ def test(): # button.resize(eSize(80, 50)) wnd.show() + + components["$002"].data["okbutton"]["instance"].push() for x in range(200): time.sleep(0.1) @@ -116,7 +118,7 @@ def test(): r = 200 - x else: r = x - components["$002"]["okbutton"].setValue(r) +# components["$002"]["okbutton"].setValue(r) desktop.paint() # @@ -131,3 +133,15 @@ def test(): return 0 + +def testI2(a): + print "PYTHON says: it's a " + str(a) + "!!!" + return 0 + +def testI(a = 0): + print "magic integer is " + str(a) + + list = testsignal.get() + print "list -> " + str(list) + list.append(testI2) + return 1 diff --git a/screens.py b/screens.py index bd0f6fc4..7287898d 100644 --- a/screens.py +++ b/screens.py @@ -31,7 +31,6 @@ class clockDisplay(Screen): b = Button("bye") b.onClick = [ self.okbutton ] self["okbutton"] = b - #VolumeBar() self["title"] = Header("clock dialog: here you see the current uhrzeit!") # defined screens -- 2.30.2