Hackish support for highlight text buttons.
authorSimon Cross <hodgestar@gmail.com>
Sun, 28 Feb 2016 21:37:51 +0000 (23:37 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sun, 28 Feb 2016 21:37:51 +0000 (23:37 +0200)
koperkapel/actors/buttons.py

index dfe0ca73a830c50d2177c8c5d2a93e7142e5292d..d6e395415f9bcfafc82872e1d04e202335629613 100644 (file)
@@ -5,8 +5,18 @@ from .surf import SurfActor
 
 
 class TextButton(SurfActor):
-    def __init__(self, text, **kwargs):
-        super(TextButton, self).__init__(getsurf(text, **kwargs))
+    def __init__(self, text, action=None, **kwargs):
+        self.text(text, **kwargs)
+        super(TextButton, self).__init__(self._surf)
+        self.action = action
 
-    def text(self, *args, **kw):
-        self.surf = getsurf(*args, **kw)
+    def select(self):
+        self.text(self._text, owidth=2, ocolor="white", color="black")
+
+    def deselect(self):
+        self.text(self._text)
+
+    def text(self, text, **kw):
+        self._text = text
+        self._text_kwargs = kw
+        self.surf = getsurf(text, **kw)