X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=koperkapel%2Factors%2Fbuttons.py;h=ac14f64d7cfc17f32d288afd27e193fca282d5a5;hb=HEAD;hp=dfe0ca73a830c50d2177c8c5d2a93e7142e5292d;hpb=5fe39c23061b1e494fc914fc46b14c9390377bc8;p=koperkapel.git diff --git a/koperkapel/actors/buttons.py b/koperkapel/actors/buttons.py index dfe0ca7..ac14f64 100644 --- a/koperkapel/actors/buttons.py +++ b/koperkapel/actors/buttons.py @@ -1,12 +1,29 @@ """ Buttons. """ +from pgzero.actor import Actor from pgzero.ptext import getsurf from .surf import SurfActor +class ImageButton(Actor): + def __init__(self, *args, action=None, **kwargs): + super().__init__(*args, **kwargs) + self.action = action + + 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().__init__(self._surf) + self.action = action + + def select(self): + self.text(self._text, owidth=2, ocolor="white", color="black") + + def deselect(self): + self.text(self._text) - def text(self, *args, **kw): - self.surf = getsurf(*args, **kw) + def text(self, text, **kw): + self._text = text + self._text_kwargs = kw + self.surf = getsurf(text, **kw)