Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions content/lib/pyswitch/clients/local/actions/message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from ....controller.callbacks import Callback
from ....controller.actions import Action

# Simple action to display a message in a display field
def DISPLAY_MESSAGE(text, display=None, color=None, id=None, enable_callback=None):
return Action({
"callback": _DisplayMessageCallback(text=text, color=color),
"display": display,
"id": id,
"enableCallback": enable_callback
})


class _DisplayMessageCallback(Callback):
def __init__(self, text, color=None):
super().__init__()
self._text = text
self._color = color

def update_displays(self):
if self.action and self.action.label:
self.action.label.text = self._text
if self._color is not None:
self.action.label.back_color = self._color