diff --git a/src/fixate/__init__.py b/src/fixate/__init__.py
index 64efbd2..c8463c6 100644
--- a/src/fixate/__init__.py
+++ b/src/fixate/__init__.py
@@ -31,10 +31,11 @@
)
from fixate._ui import (
+ Validator as Validator,
+ UiColour as UiColour,
user_input as user_input,
user_input_float as user_input_float,
user_serial as user_serial,
- Validator as Validator,
user_yes_no as user_yes_no,
user_info as user_info,
user_info_important as user_info_important,
diff --git a/src/fixate/_ui.py b/src/fixate/_ui.py
index 7960fe8..b6d70f8 100644
--- a/src/fixate/_ui.py
+++ b/src/fixate/_ui.py
@@ -6,6 +6,7 @@
from typing import Callable, Any
from queue import Queue, Empty
+from enum import StrEnum
import time
from pubsub import pub
@@ -43,6 +44,18 @@ def __str__(self) -> str:
return self.error_msg
+class UiColour(StrEnum):
+ RED = "red"
+ GREEN = "green"
+ BLUE = "blue"
+ YELLOW = "yellow"
+ WHITE = "white"
+ BLACK = "black"
+ CYAN = "cyan"
+ MAGENTA = "magenta"
+ GREY = "grey"
+
+
def _user_request_input(msg: str):
q = Queue()
pub.sendMessage("UI_block_start")
@@ -184,8 +197,10 @@ def user_info(msg: str):
pub.sendMessage("UI_display", msg=msg)
-def user_info_important(msg: str):
- pub.sendMessage("UI_display_important", msg=msg)
+def user_info_important(
+ msg: str, colour: UiColour = UiColour.RED, bg_colour: UiColour = UiColour.WHITE
+):
+ pub.sendMessage("UI_display_important", msg=msg, colour=colour, bg_colour=bg_colour)
def user_ok(msg: str):
diff --git a/src/fixate/ui_cmdline/cmd_line.py b/src/fixate/ui_cmdline/cmd_line.py
index a7e666a..af0b580 100644
--- a/src/fixate/ui_cmdline/cmd_line.py
+++ b/src/fixate/ui_cmdline/cmd_line.py
@@ -182,12 +182,13 @@ def _user_display(msg):
print(_reformat_text(msg))
-def _user_display_important(msg):
+def _user_display_important(msg, colour=None, bg_colour=None):
"""
:param msg:
:param important: creates a line of "!" either side of the message
:return:
"""
+ # ignore the colours that are used in the GUI
print("")
print("!" * wrapper.width)
print("")
diff --git a/src/fixate/ui_gui_qt/ui_gui_qt.py b/src/fixate/ui_gui_qt/ui_gui_qt.py
index 8eae88a..bba3228 100644
--- a/src/fixate/ui_gui_qt/ui_gui_qt.py
+++ b/src/fixate/ui_gui_qt/ui_gui_qt.py
@@ -775,7 +775,7 @@ def _topic_UI_display(self, msg):
self.sig_active_update.emit(self.reformat_text(msg))
self.sig_history_update.emit(self.reformat_text(msg))
- def _topic_UI_display_important(self, msg):
+ def _topic_UI_display_important(self, msg, colour="red", bg_colour="white"):
"""
:param msg:
:return:
@@ -794,9 +794,13 @@ def _topic_UI_display_important(self, msg):
self.sig_history_update.emit(txt_fill)
# Active window
- self.sig_active_update.emit(f"{txt_fill}")
+ self.sig_active_update.emit(
+ f"{txt_fill}"
+ )
self.sig_active_update.emit(self.reformat_text(msg))
- self.sig_active_update.emit(f"{txt_fill}")
+ self.sig_active_update.emit(
+ f"{txt_fill}"
+ )
def _topic_Sequence_Complete(
self, status, passed, failed, error, skipped, sequence_status