diff --git a/README.md b/README.md index e8fbaeb..7dcf003 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ -Dépendances: -- Python 2 -- PyQt -- lxml \ No newline at end of file +DĂ©pendances: +- Python 3 +- PyQt5 +- lxml + +Optional: +- pyenchant \ No newline at end of file diff --git a/TODO.t2t b/TODO.t2t index b1f7b5f..c314ad5 100644 --- a/TODO.t2t +++ b/TODO.t2t @@ -3,7 +3,4 @@ Features - Coach (entrer le nombre de mot viser, se fixer des objectifs quotidiens / hebdomadaires (en temps, ou en mots, min ou max), faire des statistiques) - DiffĂ©rents modes: simple (que le outliner / rĂ©dacteur), snowflake strict (cache les Ă©lĂ©ments tant que le prĂ©cĂ©dent n'a pas Ă©tĂ© accompli), snowflake souple (tout est affichĂ© mais permet de naviger, avec conseils) -- BoĂ®te Ă  sable: endroit pour expĂ©rimenter, des scenes particulières ou des perso en situations spĂ©ciales. Avec suggestions de thèmes / lieux / ... - -Outline: -- Afficher le nombre de mots, et la cible, et une barre de progressions \ No newline at end of file +- BoĂ®te Ă  sable: endroit pour expĂ©rimenter, des scenes particulières ou des perso en situations spĂ©ciales. Avec suggestions de thèmes / lieux / ... \ No newline at end of file diff --git a/makefile b/makefile index 1891005..6305e0d 100644 --- a/makefile +++ b/makefile @@ -5,7 +5,7 @@ UIs= $(UI:.ui=.py) $(UI:.qrc=_rc.py) ui: $(UIs) run: $(UIs) - python src/main.py + python3 src/main.py debug: $(UIs) gdb --args python src/main.py @@ -14,13 +14,13 @@ lineprof: kernprof -l -v src/main.py profile: - python -m cProfile -s 'cumtime' src/main.py | more + python3 -m cProfile -s 'cumtime' src/main.py | more compile: - cd src && python setup.py build_ext --inplace + cd src && python3 setup.py build_ext --inplace %_rc.py : %.qrc - pyrcc4 "$<" -o "$@" + pyrcc5 "$<" -o "$@" %.py : %.ui # pyuic4 "$<" > "$@" diff --git a/src/enums.py b/src/enums.py index 42cdb29..96b2c66 100644 --- a/src/enums.py +++ b/src/enums.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + # As seen on http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python diff --git a/src/functions.py b/src/functions.py index 6c13ab7..07d36c2 100644 --- a/src/functions.py +++ b/src/functions.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * diff --git a/src/loadSave.py b/src/loadSave.py index de3d045..e574861 100644 --- a/src/loadSave.py +++ b/src/loadSave.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * @@ -16,26 +16,26 @@ def saveStandardItemModelXML(mdl, xml): vHeader = ET.SubElement(header, "vertical") for x in range(mdl.rowCount()): vH = ET.SubElement(vHeader, "label") - vH.attrib["row"] = unicode(x) - vH.attrib["text"] = unicode(mdl.headerData(x, Qt.Vertical)) + vH.attrib["row"] = str(x) + vH.attrib["text"] = str(mdl.headerData(x, Qt.Vertical)) hHeader = ET.SubElement(header, "horizontal") for y in range(mdl.columnCount()): hH = ET.SubElement(hHeader, "label") - hH.attrib["row"] = unicode(y) - hH.attrib["text"] = unicode(mdl.headerData(y, Qt.Horizontal)) + hH.attrib["row"] = str(y) + hH.attrib["text"] = str(mdl.headerData(y, Qt.Horizontal)) # Data data = ET.SubElement(root, "data") for x in range(mdl.rowCount()): row = ET.SubElement(data, "row") - row.attrib["row"] = unicode(x) + row.attrib["row"] = str(x) for y in range(mdl.columnCount()): col = ET.SubElement(row, "col") - col.attrib["col"] = unicode(y) - if mdl.data(mdl.index(x, y)) <> "": + col.attrib["col"] = str(y) + if mdl.data(mdl.index(x, y)) != "": col.text = mdl.data(mdl.index(x, y)) print("Saving to {}.".format(xml)) diff --git a/src/main.py b/src/main.py index eb560e3..8480c5f 100644 --- a/src/main.py +++ b/src/main.py @@ -4,7 +4,7 @@ import sys from qt import * -if __name__ == "__main__": +def run(): app = QApplication(sys.argv) app.setOrganizationName("Theologeek") app.setOrganizationDomain("www.theologeek.ch") @@ -20,3 +20,6 @@ if __name__ == "__main__": app.exec_() app.deleteLater() + +if __name__ == "__main__": + run() \ No newline at end of file diff --git a/src/mainWindow.py b/src/mainWindow.py index 3eb904a..f6bbcbb 100644 --- a/src/mainWindow.py +++ b/src/mainWindow.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * @@ -23,7 +23,7 @@ except ImportError: class MainWindow(QMainWindow, Ui_MainWindow): - dictChanged = pyqtSignal(unicode) + dictChanged = pyqtSignal(str) def __init__(self): QMainWindow.__init__(self) @@ -228,8 +228,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.treeDebugOutline.setModel(self.mdlOutline) # Playing with qStyle - self.cmbStyle.addItems(QStyleFactory.keys()) - self.cmbStyle.setCurrentIndex([i.lower() for i in QStyleFactory.keys()].index(qApp.style().objectName())) + self.cmbStyle.addItems(list(QStyleFactory.keys())) + self.cmbStyle.setCurrentIndex([i.lower() for i in list(QStyleFactory.keys())].index(qApp.style().objectName())) self.cmbStyle.currentIndexChanged[str].connect(qApp.setStyle) self.loadProject("test_project") @@ -264,7 +264,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): stretch = Outline.title.value w2 = 0 for c in range(self.mdlOutline.columnCount()): - if not self.treePlanOutline.isColumnHidden(c) and c <> stretch: + if not self.treePlanOutline.isColumnHidden(c) and c != stretch: self.treePlanOutline.resizeColumnToContents(c) w2 += self.treePlanOutline.columnWidth(c) @@ -321,7 +321,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): pid = self.mdlPersos.item(idx.row(), Perso.ID.value).text() for c in range(self.mdlPersosInfos.columnCount()): pid2 = self.mdlPersosInfos.item(0, c).text() - self.tblPersoInfos.setColumnHidden(c, c <> 0 and pid <> pid2) + self.tblPersoInfos.setColumnHidden(c, c != 0 and pid != pid2) self.resizePersosInfos() @@ -465,10 +465,10 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.menuDictGroup = QActionGroup(self) for i in enchant.list_dicts(): - a = QAction(unicode(i[0]), self) + a = QAction(str(i[0]), self) a.setCheckable(True) a.triggered.connect(self.setDictionary) - if unicode(i[0]) == enchant.get_default_language(): # "fr_CH" + if str(i[0]) == enchant.get_default_language(): # "fr_CH" a.setChecked(True) self.menuDictGroup.addAction(a) self.menuDict.addAction(a) diff --git a/src/models/outlineModel.py b/src/models/outlineModel.py index 94ba13c..9077559 100644 --- a/src/models/outlineModel.py +++ b/src/models/outlineModel.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * from enums import * @@ -199,7 +199,7 @@ class outlineModel(QAbstractItemModel): if column > 0: column = 0 - if row <> -1: + if row != -1: beginRow = row elif parent.isValid(): beginRow = self.rowCount(parent) + 1 @@ -210,7 +210,7 @@ class outlineModel(QAbstractItemModel): root = ET.XML(encodedData) - if root.tag <> "outlineItems": + if root.tag != "outlineItems": return False items = [] @@ -234,7 +234,7 @@ class outlineModel(QAbstractItemModel): else: parentItem = parent.internalPointer() - if parent.isValid() and parent.column() <> 0: + if parent.isValid() and parent.column() != 0: parent = parentItem.index() # Insert only if parent is folder @@ -257,7 +257,7 @@ class outlineModel(QAbstractItemModel): else: parentItem = parent.internalPointer() - if parent.isValid() and parent.column() <> 0: + if parent.isValid() and parent.column() != 0: parent = parentItem.index() # If parent is folder, write into @@ -418,7 +418,7 @@ class outlineItem(): updateWordCount = False if column in [Outline.wordCount.value, Outline.goal.value, Outline.setGoal.value]: - updateWordCount = not Outline(column) in self._data or self._data[Outline(column)] <> data + updateWordCount = not Outline(column) in self._data or self._data[Outline(column)] != data self._data[Outline(column)] = data @@ -434,7 +434,7 @@ class outlineItem(): setGoal = toInt(self.data(Outline.setGoal.value)) goal = toInt(self.data(Outline.goal.value)) - if goal <> setGoal: + if goal != setGoal: self._data[Outline.goal] = setGoal if setGoal: wc = toInt(self.data(Outline.wordCount.value)) @@ -450,7 +450,7 @@ class outlineItem(): goal = toInt(self.data(Outline.goal.value)) if setGoal: - if goal <> setGoal: + if goal != setGoal: self._data[Outline.goal] = setGoal else: goal = 0 @@ -540,7 +540,7 @@ class outlineItem(): if attrib in exclude: continue val = self.data(attrib.value) if val or attrib in force: - item.set(attrib.name, unicode(val)) + item.set(attrib.name, str(val)) for i in self.childItems: item.append(ET.XML(i.toXML())) @@ -555,7 +555,7 @@ class outlineItem(): #if k == Outline.compile: #self.setData(Outline.__members__[k].value, unicode(root.attrib[k]), Qt.CheckStateRole) #else: - self.setData(Outline.__members__[k].value, unicode(root.attrib[k])) + self.setData(Outline.__members__[k].value, str(root.attrib[k])) for child in root: item = outlineItem(self._model, xml=ET.tostring(child)) diff --git a/src/models/persosProxyModel.py b/src/models/persosProxyModel.py index a05466f..47d87d1 100644 --- a/src/models/persosProxyModel.py +++ b/src/models/persosProxyModel.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * from enums import * diff --git a/src/ui/chkOutlineCompile.py b/src/ui/chkOutlineCompile.py index 76cb9e8..141eec7 100644 --- a/src/ui/chkOutlineCompile.py +++ b/src/ui/chkOutlineCompile.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * from enums import * diff --git a/src/ui/cmbOutlinePersoChoser.py b/src/ui/cmbOutlinePersoChoser.py index d5b78de..2077aa7 100644 --- a/src/ui/cmbOutlinePersoChoser.py +++ b/src/ui/cmbOutlinePersoChoser.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * from enums import * @@ -27,7 +27,7 @@ class cmbOutlinePersoChoser(QComboBox): item = self.currentModelIndex.internalPointer() POV = item.data(Outline.POV.value) idx = self.findData(POV) - if idx <> -1: + if idx != -1: self.setCurrentIndex(idx) else: self.setCurrentIndex(0) diff --git a/src/ui/cmbOutlineStatusChoser.py b/src/ui/cmbOutlineStatusChoser.py index 6a2198f..0f4940c 100644 --- a/src/ui/cmbOutlineStatusChoser.py +++ b/src/ui/cmbOutlineStatusChoser.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * from enums import * diff --git a/src/ui/collapsibleGroupBox.py b/src/ui/collapsibleGroupBox.py index bd082d3..0f71f4f 100644 --- a/src/ui/collapsibleGroupBox.py +++ b/src/ui/collapsibleGroupBox.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * diff --git a/src/ui/collapsibleGroupBox2.py b/src/ui/collapsibleGroupBox2.py index 9721b32..b3eff51 100644 --- a/src/ui/collapsibleGroupBox2.py +++ b/src/ui/collapsibleGroupBox2.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * diff --git a/src/ui/editors/customTextEdit.py b/src/ui/editors/customTextEdit.py index c6e9ea2..0c3b8f1 100644 --- a/src/ui/editors/customTextEdit.py +++ b/src/ui/editors/customTextEdit.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * from enums import * @@ -54,9 +54,11 @@ class customTextEdit(QTextEdit): # Spellchecking if enchant and self.spellcheck: self.dict = enchant.Dict(self.currentDict if self.currentDict else enchant.get_default_language()) + else: + self.spellcheck = False def submit(self): - if self.toPlainText() <> self.item.data(Outline.text.value): + if self.toPlainText() != self.item.data(Outline.text.value): #self._model.setData(self.item.index(), self.toPlainText(), Outline.text.value) self.item.setData(Outline.text.value, self.toPlainText()) @@ -66,7 +68,7 @@ class customTextEdit(QTextEdit): def updateText(self): if self.item: - if self.toPlainText() <> self.item.data(Outline.text.value): + if self.toPlainText() != self.item.data(Outline.text.value): self.document().setPlainText(self.item.data(Outline.text.value)) def resizeEvent(self, e): @@ -102,13 +104,13 @@ class customTextEdit(QTextEdit): class SpellAction(QAction): "A special QAction that returns the text in a signal. Used for spellckech." - correct = pyqtSignal(unicode) + correct = pyqtSignal(str) def __init__(self, *args): QAction.__init__(self, *args) self.triggered.connect(lambda x: self.correct.emit( - unicode(self.text()))) + str(self.text()))) def contextMenuEvent(self, event): # Based on http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/ @@ -127,7 +129,7 @@ class customTextEdit(QTextEdit): # Check if the selected word is misspelled and offer spelling # suggestions if it is. if self.textCursor().hasSelection(): - text = unicode(self.textCursor().selectedText()) + text = str(self.textCursor().selectedText()) if not self.dict.check(text): spell_menu = QMenu('Spelling Suggestions') for word in self.dict.suggest(text): diff --git a/src/ui/editors/editorWidget.py b/src/ui/editors/editorWidget.py index 2bcd704..83d0856 100644 --- a/src/ui/editors/editorWidget.py +++ b/src/ui/editors/editorWidget.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * from enums import * @@ -142,7 +142,6 @@ class editorWidget(QWidget, Ui_editorWidget_ui): currentScreen = qApp.desktop().screenNumber(self) self.setParent(None) mainWindow().hide() - self.move(qApp.desktop().screenGeometry(currentScreen).topLeft()) self.stack.setStyleSheet(""" QTextEdit {{ @@ -152,8 +151,12 @@ class editorWidget(QWidget, Ui_editorWidget_ui): m=str((qApp.desktop().screenGeometry(currentScreen).width() - 800) / 2)) ) + self.move(qApp.desktop().screenGeometry(currentScreen).topLeft()) QWidget.showFullScreen(self) + #FIXME: too big? + print(qApp.desktop().screenGeometry(currentScreen), self.geometry()) + def keyPressEvent(self, event): diff --git a/src/ui/editors/t2tFunctions.py b/src/ui/editors/t2tFunctions.py index 262bc36..770c72c 100644 --- a/src/ui/editors/t2tFunctions.py +++ b/src/ui/editors/t2tFunctions.py @@ -113,7 +113,7 @@ def translateSelectionToFormattedText(text, start, end): def printArray(array): - print("".join([str(j) for j in array])) + print(("".join([str(j) for j in array]))) def printArrays(arrays): @@ -235,7 +235,7 @@ class State: LIST_EMPTY = 42 LIST_BULLET = 43 LIST_BULLET_ENDS = 44 - LIST = [40, 41, 42] + range(100, 201) + LIST = [40, 41, 42] + list(range(100, 201)) # TABLE TABLE_LINE = 50 TABLE_HEADER = 51 diff --git a/src/ui/editors/t2tHighlighter.py b/src/ui/editors/t2tHighlighter.py index 113740e..8ed7745 100644 --- a/src/ui/editors/t2tHighlighter.py +++ b/src/ui/editors/t2tHighlighter.py @@ -317,7 +317,7 @@ class t2tHighlighter (QSyntaxHighlighter): # Spell checking # Based on http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/ - WORDS = u'(?iu)[\w\']+' + WORDS = '(?iu)[\w\']+' if state not in [State.SETTINGS_LINE]: if self.editor.spellcheck: for word_object in re.finditer(WORDS, text): @@ -357,7 +357,7 @@ class t2tHighlighter (QSyntaxHighlighter): blankLinesBefore = 0 #if text.contains(QRegExp(r'^\s*[-+:] [^ ].*[^-+]{1}\s*$')): - if QRegExp(r'^\s*[-+:] [^ ].*[^-+]{1}\s*$').indexIn(text) <> -1: + if QRegExp(r'^\s*[-+:] [^ ].*[^-+]{1}\s*$').indexIn(text) != -1: state = State.LIST_BEGINS # List stuff @@ -390,7 +390,7 @@ class t2tHighlighter (QSyntaxHighlighter): # Blank lines before (two = end of list) blankLinesBefore = self.getBlankLines(block.previous()) - if not QRegExp(r'^\s*$').indexIn(block.previous().text()) <> -1 and \ + if not QRegExp(r'^\s*$').indexIn(block.previous().text()) != -1 and \ not blockUserData.getUserState(block.previous()) in [State.COMMENT_LINE, State.COMMENT_AREA, State.COMMENT_AREA_BEGINS, State.COMMENT_AREA_ENDS]: @@ -403,7 +403,7 @@ class t2tHighlighter (QSyntaxHighlighter): # End of list. blankLinesBefore = 0 inList = False - if inList and QRegExp(r'^\s*$').indexIn(text) <> -1: + if inList and QRegExp(r'^\s*$').indexIn(text) != -1: state = State.LIST_EMPTY # Areas @@ -414,7 +414,7 @@ class t2tHighlighter (QSyntaxHighlighter): (State.TAGGED_AREA_BEGINS, State.TAGGED_AREA, State.TAGGED_AREA_ENDS, '^\'\'\'\s*$'), ]: - if QRegExp(marker).indexIn(text) <> -1: + if QRegExp(marker).indexIn(text) != -1: if blockUserData.getUserState(block.previous()) in [begins, middle]: state = ends break @@ -509,7 +509,7 @@ class t2tHighlighter (QSyntaxHighlighter): d = QDir.cleanPath(QFileInfo(f).absoluteDir().absolutePath()+"/"+c) file = codecs.open(d, 'r', "utf-8") except: - print("Error: cannot open {}.".format(c)) + print(("Error: cannot open {}.".format(c))) continue # We add the content to the current lines of the current document lines += file.readlines() #lines.extend(file.readlines()) @@ -520,7 +520,7 @@ class t2tHighlighter (QSyntaxHighlighter): #while b.isValid(): for l in lines: text = l #b.text() - r = QRegExp(ur'^%!p[or][se]t?proc[^\s]*\s*:\s*(\'[^\']*\'|\"[^\"]*\")\s*(\'[^\']*\'|\"[^\"]*\")') + r = QRegExp(r'^%!p[or][se]t?proc[^\s]*\s*:\s*(\'[^\']*\'|\"[^\"]*\")\s*(\'[^\']*\'|\"[^\"]*\")') if r.indexIn(text) != -1: rule = r.cap(1)[1:-1] # Check if there was a color-comment above that post/preproc bloc diff --git a/src/ui/helpLabel.py b/src/ui/helpLabel.py index 10a6b8c..82ae2fb 100644 --- a/src/ui/helpLabel.py +++ b/src/ui/helpLabel.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * diff --git a/src/ui/sldImportance.py b/src/ui/sldImportance.py index 48145b0..95d324d 100644 --- a/src/ui/sldImportance.py +++ b/src/ui/sldImportance.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * @@ -34,7 +34,7 @@ class sldImportance(QWidget, Ui_sldImportance): self.importanceChanged.emit(str(v)) def setValue(self, v): - if v <> self.lastValue: + if v != self.lastValue: self.sld.setValue(int(v) if v else 0) self.changed(int(v) if v else 0) self.lastValue = v diff --git a/src/ui/treeOutlineDelegates.py b/src/ui/treeOutlineDelegates.py index f0ee7cf..2d5a8b2 100644 --- a/src/ui/treeOutlineDelegates.py +++ b/src/ui/treeOutlineDelegates.py @@ -1,8 +1,8 @@ #!/usr/bin/env python #--!-- coding: utf8 --!-- -from __future__ import print_function -from __future__ import unicode_literals + + from qt import * from enums import * diff --git a/test_project/outline.xml b/test_project/outline.xml index f873ab2..fdbd1d3 100644 --- a/test_project/outline.xml +++ b/test_project/outline.xml @@ -1,9 +1,9 @@ - + - + @@ -15,12 +15,12 @@ - + + - - +