From b40e4635d9cde3096c864b63eb6c3526f46cfecc Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Thu, 8 Oct 2020 00:06:17 +0200 Subject: [PATCH] Further number formatting improvements --- nw/gui/doceditor.py | 4 ++-- nw/gui/docviewer.py | 6 ------ nw/gui/itemdetails.py | 12 ++++++------ nw/gui/outline.py | 6 +++--- nw/gui/projsettings.py | 6 +++--- nw/gui/writingstats.py | 9 +++++---- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index f805e5ae..ba0b1945 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -2273,10 +2273,10 @@ class GuiDocEditFooter(QWidget): wCount = self.theItem.wordCount wDiff = wCount - self.theItem.initCount - self.wordsText.setText("Words: {:n} ({:+n})".format(wCount, wDiff)) + self.wordsText.setText(f"Words: {wCount:n} ({wDiff:+n})") byteSize = self.docEditor.qDocument.characterCount() - self.wordsText.setToolTip("Document size is {:n} bytes".format(byteSize)) + self.wordsText.setToolTip(f"Document size is {byteSize:n} bytes") return diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index 49f9c9da..b7404e9c 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -502,12 +502,6 @@ class GuiDocViewer(QTextBrowser): "mark {{" " color: rgb({eColR},{eColG},{eColB});" "}}\n" - "table {{" - " margin: 10px 0px;" - "}}\n" - "td {{" - " padding: 0px 4px;" - "}}\n" ".tags {{" " color: rgb({kColR},{kColG},{kColB});" " font-wright: bold;" diff --git a/nw/gui/itemdetails.py b/nw/gui/itemdetails.py index f64d570b..6d5cbcb5 100644 --- a/nw/gui/itemdetails.py +++ b/nw/gui/itemdetails.py @@ -195,9 +195,9 @@ class GuiItemDetails(QWidget): we're already showing. """ if tHandle == self.theHandle: - self.cCountData.setText("{:n}".format(cC)) - self.wCountData.setText("{:n}".format(wC)) - self.pCountData.setText("{:n}".format(pC)) + self.cCountData.setText(f"{cC:n}") + self.wCountData.setText(f"{wC:n}") + self.pCountData.setText(f"{pC:n}") return def updateViewBox(self, tHandle): @@ -252,9 +252,9 @@ class GuiItemDetails(QWidget): self.layoutData.setText(nwLabels.LAYOUT_NAME[nwItem.itemLayout]) if nwItem.itemType == nwItemType.FILE: - self.cCountData.setText("{:n}".format(nwItem.charCount)) - self.wCountData.setText("{:n}".format(nwItem.wordCount)) - self.pCountData.setText("{:n}".format(nwItem.paraCount)) + self.cCountData.setText(f"{nwItem.charCount:n}") + self.wCountData.setText(f"{nwItem.wordCount:n}") + self.pCountData.setText(f"{nwItem.paraCount:n}") else: self.cCountData.setText("–") self.wCountData.setText("–") diff --git a/nw/gui/outline.py b/nw/gui/outline.py index fcee1d8c..6d524992 100644 --- a/nw/gui/outline.py +++ b/nw/gui/outline.py @@ -431,9 +431,9 @@ class GuiOutline(QTreeWidget): newItem.setText(self.colIndex[nwOutline.LINE], sTitle[1:].lstrip("0")) newItem.setData(self.colIndex[nwOutline.LINE], Qt.UserRole, sTitle) newItem.setText(self.colIndex[nwOutline.SYNOP], novIdx["synopsis"]) - newItem.setText(self.colIndex[nwOutline.CCOUNT], str(novIdx["cCount"])) - newItem.setText(self.colIndex[nwOutline.WCOUNT], str(novIdx["wCount"])) - newItem.setText(self.colIndex[nwOutline.PCOUNT], str(novIdx["pCount"])) + newItem.setText(self.colIndex[nwOutline.CCOUNT], "{:n}".format(novIdx["cCount"])) + newItem.setText(self.colIndex[nwOutline.WCOUNT], "{:n}".format(novIdx["wCount"])) + newItem.setText(self.colIndex[nwOutline.PCOUNT], "{:n}".format(novIdx["pCount"])) newItem.setTextAlignment(self.colIndex[nwOutline.CCOUNT], Qt.AlignRight) newItem.setTextAlignment(self.colIndex[nwOutline.WCOUNT], Qt.AlignRight) newItem.setTextAlignment(self.colIndex[nwOutline.PCOUNT], Qt.AlignRight) diff --git a/nw/gui/projsettings.py b/nw/gui/projsettings.py index 998ec83c..30d9ad54 100644 --- a/nw/gui/projsettings.py +++ b/nw/gui/projsettings.py @@ -282,15 +282,15 @@ class GuiProjectEditMeta(QWidget): self.nRootLabel = QLabel("Root folders:") self.nRootLabel.setIndent(xInd) - self.nRootValue = QLabel("{:n}".format(nR)) + self.nRootValue = QLabel(f"{nR:n}") self.nDirLabel = QLabel("Folders:") self.nDirLabel.setIndent(xInd) - self.nDirValue = QLabel("{:n}".format(nD)) + self.nDirValue = QLabel(f"{nD:n}") self.nFileLabel = QLabel("Documents:") self.nFileLabel.setIndent(xInd) - self.nFileValue = QLabel("{:n}".format(nF)) + self.nFileValue = QLabel(f"{nF:n}") self.wordsLabel = QLabel("Word count:") self.wordsLabel.setIndent(xInd) diff --git a/nw/gui/writingstats.py b/nw/gui/writingstats.py index 1d634ec6..ccf1ce18 100644 --- a/nw/gui/writingstats.py +++ b/nw/gui/writingstats.py @@ -454,10 +454,11 @@ class GuiWritingStats(QDialog): ) return False + ttWords = ttNovel + ttNotes self.labelTotal.setText(self._formatTime(ttTime)) - self.novelWords.setText("{:n}".format(ttNovel)) - self.notesWords.setText("{:n}".format(ttNotes)) - self.totalWords.setText("{:n}".format(ttNovel + ttNotes)) + self.novelWords.setText(f"{ttNovel:n}") + self.notesWords.setText(f"{ttNotes:n}") + self.totalWords.setText(f"{ttWords:n}") return True @@ -544,7 +545,7 @@ class GuiWritingStats(QDialog): newItem = QTreeWidgetItem() newItem.setText(self.C_TIME, sStart) newItem.setText(self.C_LENGTH, self._formatTime(sDiff)) - newItem.setText(self.C_COUNT, "{:n}".format(nWords)) + newItem.setText(self.C_COUNT, f"{nWords:n}") if nWords > 0 and listMax > 0: theBar = self.barImage.scaled(