Skip to content

Commit

Permalink
add a bit more flexibility for the user_info_important colours in the…
Browse files Browse the repository at this point in the history
… GUI
  • Loading branch information
jcollins1983 committed Sep 1, 2024
1 parent 4e7428c commit 46f3f47
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/fixate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 17 additions & 2 deletions src/fixate/_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from typing import Callable, Any
from queue import Queue, Empty
from enum import StrEnum
import time
from pubsub import pub

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion src/fixate/ui_cmdline/cmd_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
Expand Down
10 changes: 7 additions & 3 deletions src/fixate/ui_gui_qt/ui_gui_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"<span style='color:red;'>{txt_fill}</span>")
self.sig_active_update.emit(
f"<span style='color:{colour};background-color:{bg_colour}'>{txt_fill}</span>"
)
self.sig_active_update.emit(self.reformat_text(msg))
self.sig_active_update.emit(f"<span style='color:red;'>{txt_fill}</span>")
self.sig_active_update.emit(
f"<span style='color:{colour};background-color:{bg_colour}'>{txt_fill}</span>"
)

def _topic_Sequence_Complete(
self, status, passed, failed, error, skipped, sequence_status
Expand Down

0 comments on commit 46f3f47

Please sign in to comment.