From 1b861b1b2c15ec617051b746f8d207fca11cb869 Mon Sep 17 00:00:00 2001 From: Louie S Date: Sat, 16 Sep 2023 09:36:14 -0400 Subject: Manual entry coloring working --- entry.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'entry.py') diff --git a/entry.py b/entry.py index 0254093..0ff173a 100644 --- a/entry.py +++ b/entry.py @@ -3,13 +3,15 @@ from PyQt5.QtGui import QFont from PyQt5.QtWidgets import QHBoxLayout, QLabel class Entry: - def __init__(self, id, parent_id, desc, due = "", due_alt = "", link = "", done = False, hidden = False): + def __init__(self, id, parent_id, desc, due = "", due_alt = "", link = "", color = "", highlight = "", done = False, hidden = False): self.id = id self.parent_id = parent_id self.desc = desc self.due = due self.due_alt = due_alt self.link = link + self.color = color + self.highlight = highlight self.done = done self.hidden = hidden @@ -31,11 +33,6 @@ class Entry: color: green; } """) - body.setStyleSheet(""" - QLabel{ - color: green; - } - """) else: bullet.setText("- ") output.addWidget(bullet) @@ -44,7 +41,7 @@ class Entry: body.setText("{0}/{1}/{2}: ".format(self.due.month(), self.due.day(), self.due.year())) if self.link: body.setOpenExternalLinks(True) - body.setText(body.text() + "".format(self.link)) + body.setText(body.text() + "".format(self.link)) body.setText(body.text() + self.desc) if self.link: body.setText(body.text() + "") @@ -56,5 +53,20 @@ class Entry: font = body.font() font.setStrikeOut(True) body.setFont(font) + body.setStyleSheet(""" + QLabel{ + color: green; + } + """) + + else: + body.setStyleSheet(""" + QLabel{{ + color: {0}; + background-color: {1}; + }}""".format( + self.color if self.color else "black", + self.highlight if self.highlight else "none" + )) return output -- cgit