From 57c7fdcf6dedd8bed5f2126b3c06b73a7b078bcd Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 5 Jul 2020 23:25:29 +0200 Subject: [PATCH 1/2] Fixed typo in tooltip --- nw/gui/docviewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index f20d9082..50c86b72 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -595,7 +595,7 @@ class GuiDocViewFooter(QWidget): self.showHide.setIconSize(QSize(fPx, fPx)) self.showHide.setFixedSize(QSize(fPx, fPx)) self.showHide.clicked.connect(self._doShowHide) - self.showHide.setToolTip("Show/hide the reference panel") + self.showHide.setToolTip("Show/hide the references panel") # Sticky Button stickyOn = self.theTheme.getPixmap("sticky-on", (fPx, fPx)) From a14850de659e933d459b120702728fef23174b64 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Mon, 6 Jul 2020 08:16:22 +0200 Subject: [PATCH 2/2] Improved the roman number function and fixed a bug in it --- nw/core/tools.py | 14 ++++++++------ nw/gui/build.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/nw/core/tools.py b/nw/core/tools.py index c4455ff1..dd2c8c84 100644 --- a/nw/core/tools.py +++ b/nw/core/tools.py @@ -91,23 +91,25 @@ def countWords(theText): def numberToRoman(numVal, isLower=False): """Convert an integer to a roman number. """ - if numVal < 1 or numVal > 4999: + if not isinstance(numVal, int): return "NAN" + if numVal < 1 or numVal > 4999: + return "OOR" - theValues = [ + theValues = [ (1000, "M"), (900, "CM"), (500, "D"), (400, "CD"), (100, "C"), (90, "XC"), (50, "L"), (40, "XL"), (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"), ] romNum = "" for theDiv, theSym in theValues: - for _ in range(numVal//theDiv): - romNum += theSym - numVal -= theDiv + n = numVal//theDiv + romNum += n*theSym + numVal -= n*theDiv if numVal <= 0: break - return romNum.lower if isLower else romNum + return romNum.lower() if isLower else romNum # =============================================================================================== # # Convert an Integer to a Word Number diff --git a/nw/gui/build.py b/nw/gui/build.py index 7220639b..34a01f05 100644 --- a/nw/gui/build.py +++ b/nw/gui/build.py @@ -46,7 +46,7 @@ from PyQt5.QtWidgets import ( from nw.common import fuzzyTime from nw.gui.custom import QSwitch -from nw.core import ToHtml, numberToRoman +from nw.core import ToHtml from nw.constants import ( nwAlert, nwFiles, nwItemType, nwItemLayout, nwItemClass )