Hack keyboard behaviour to be different. Also incidently allow rotating in place
[koperkapel.git] / koperkapel / actors / buttons.py
1 """ Buttons. """
2
3 from pgzero.actor import Actor
4 from pgzero.ptext import getsurf
5 from .surf import SurfActor
6
7
8 class ImageButton(Actor):
9     def __init__(self, *args, action=None, **kwargs):
10         super().__init__(*args, **kwargs)
11         self.action = action
12
13
14 class TextButton(SurfActor):
15     def __init__(self, text, action=None, **kwargs):
16         self.text(text, **kwargs)
17         super().__init__(self._surf)
18         self.action = action
19
20     def select(self):
21         self.text(self._text, owidth=2, ocolor="white", color="black")
22
23     def deselect(self):
24         self.text(self._text)
25
26     def text(self, text, **kw):
27         self._text = text
28         self._text_kwargs = kw
29         self.surf = getsurf(text, **kw)