From 604b485fab100785c4def10dc7242e6408e1f1c6 Mon Sep 17 00:00:00 2001 From: Louie S Date: Sat, 16 Sep 2023 09:36:14 -0400 Subject: Create project using setuptools --- src/entry.py | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/entry.py (limited to 'src/entry.py') diff --git a/src/entry.py b/src/entry.py new file mode 100644 index 0000000..addc96a --- /dev/null +++ b/src/entry.py @@ -0,0 +1,84 @@ +from datetime import date, datetime +from PyQt5.QtCore import Qt +from PyQt5.QtGui import QFont +from PyQt5.QtWidgets import QHBoxLayout, QLabel + +class Entry: + 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 + + def buildLayout(self): + output = QHBoxLayout() + bullet = QLabel() + body = QLabel() + + bullet.setFont(QFont("Arial", 11)) + + body.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.LinksAccessibleByMouse) + body.setFont(QFont("Arial", 11)) + body.setWordWrap(True) + body.setToolTip("Right-Click for actions") + + if self.done: + bullet.setText("\u2713 ") + bullet.setStyleSheet(""" + QLabel{ + color: green; + } + """) + else: + bullet.setText("- ") + output.addWidget(bullet) + + if self.due: + 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, + self.color if self.color else "default" + )) + body.setText(body.text() + self.desc) + if self.link: + body.setText(body.text() + "") + body.setToolTip("{}".format(self.link)) + output.addWidget(body) + + output.addStretch() + + if self.done: + font = body.font() + font.setStrikeOut(True) + body.setFont(font) + body.setStyleSheet(""" + QLabel{ + color: green; + } + """) + + else: + body.setStyleSheet(""" + QLabel{{ + color: {0}; + background-color: {1}; + font-weight: {2}; + }}""".format( + self.color if self.color else "default", + self.highlight if self.highlight else "none", + "bold" if self.due and self.due <= date.today() else "normal" + )) + + return output -- cgit