Example #1
0
    def __init__(self, parent = None, file = None):
        super(EditorWindow, self).__init__(parent)
        self.setupUi(self)
        self.doubleSpinBox.setValue(12)
        # self.fontComboBox.setWritingSystem()

        # backColor = QAction(QIcon("icons/backcolor.png"),"Change background color",self)

        self.actionNew.triggered.connect(lambda: self.NewFile(existing=True))
        # self.actionNew.triggered.connect(lambda: NewFile(self, self.titleTemplate,  existing=True))
        self.actionOpen.triggered.connect(lambda: self.OpenFile(None))
        # self.actionOpen.triggered.connect(lambda: OpenFile(self, None))
        self.actionSave.triggered.connect(self.Save)
        # self.actionSave.triggered.connect(lambda: Save(self))
        self.actionExit.triggered.connect(lambda: sys.exit() if self.Exit() is 2 or self.Exit is 0 else None)
        self.actionSave_as.triggered.connect(self.Save_as)
        # self.actionSave_as.triggered.connect(lambda: Save_as(self))
        self.actionAcerca_de.triggered.connect(functions.about.about)
        self.actionAbout_QT.triggered.connect(functions.about.about_qt)
        self.actionText_Colour.triggered.connect(lambda: self.change_text_colour("Text"))
        self.actionbackground_color.triggered.connect(lambda: self.change_text_colour("Background"))
        
        self.actionBold.triggered.connect(lambda: self.text_format("Bold"))
        self.actionItalic.triggered.connect(lambda: self.text_format("Italic"))
        self.actionUnderline.triggered.connect(lambda: self.text_format("Underline"))

        ###     NEW     ###
        #self.findAction.triggered.connect(lambda: find.Find(self).show)
        self.findAction.triggered.connect(find.Find(self).show)
        ###             ###

        self.actionCopy.triggered.connect(lambda: self.textEdit.copy())
        self.actionPaste.triggered.connect(lambda: self.textEdit.paste() if self.textEdit.canPaste() else None)
        self.actionCut.triggered.connect(lambda: self.textEdit.cut())

        self.textEdit.setUndoRedoEnabled(True)

        self.textEdit.textChanged.connect(lambda: self.setWindowModified(True))

        self.textEdit.cursorPositionChanged.connect(self.UpdateLineCol)
        #self.textEdit.cursorPositionChanged.connect(self.updateFont)
        self.fontComboBox.currentFontChanged.connect(self.updateFont)
        self.doubleSpinBox.valueChanged.connect(self.updateFont)

        # self.textEdit.cursorPositionChanged.connect(self.autosave)

        self.statusbar.showMessage("Ln 1, Col 1")
        self.fontComboBox.setEditable(False)

        self.toolBar.addWidget(self.fontComboBox)
        self.toolBar.addWidget(self.doubleSpinBox)
        # self.toolBar.addAction(backColor)

        self.titleTemplate = "[*]"
        self.filename = file

        self.actionCambiar_Fondo.triggered.connect(self.Backgroud_Color)


        if file is not None and not os.path.exists(self.filename):
            self.filename = None
        
        if self.filename is None:
            self.NewFile()
        else:
            self.OpenFile(self.filename)
            self._baseFile  = os.path.basename(self.filename)

        print(self.windowTitle())
Example #2
0
    def initToolbar(self):

        self.newAction = QtWidgets.QAction(QtGui.QIcon('icons/new.png'), 'New', self)
        self.newAction.setStatusTip('Create a new document from scratch')
        self.newAction.setShortcut('Ctrl+N')
        self.newAction.triggered.connect(self.new)

        self.openAction = QtWidgets.QAction(QtGui.QIcon('icons/open.png'), 'Open file', self)
        self.openAction.setStatusTip('Open existing document')
        self.openAction.setShortcut('Ctrl+O')
        self.openAction.triggered.connect(self.open)

        self.saveAction = QtWidgets.QAction(QtGui.QIcon('icons/save.png'), 'Save', self)
        self.saveAction.setStatusTip('Save document')
        self.saveAction.setShortcut('Ctrl+S')
        self.saveAction.triggered.connect(self.save)

        self.printAction = QtWidgets.QAction(QtGui.QIcon('icons/print.png'), 'Print document', self)
        self.printAction.setStatusTip('Print docuement')
        self.printAction.setShortcut('Ctrl+P')
        self.printAction.triggered.connect(self.printHandler)

        self.previewAction = QtWidgets.QAction(QtGui.QIcon('icons/preview.png'), 'Page view', self)
        self.previewAction.setStatusTip('Preview page before printing')
        self.previewAction.setShortcut('Ctrl+Shift+P')
        self.previewAction.triggered.connect(self.preview)

        self.findAction = QtWidgets.QAction(QtGui.QIcon('icons/find.png'), 'Find and replace', self)
        self.findAction.setStatusTip('Find and replace words in your document')
        self.findAction.setShortcut('Ctrl+F')
        self.findAction.triggered.connect(find.Find(self).show)

        self.cutAction = QtWidgets.QAction(QtGui.QIcon('icons/cut.png'), 'Cut to clipboard', self)
        self.cutAction.setStatusTip('Delete and copy text to clipboard')
        self.cutAction.setShortcut('Ctrl+X')
        self.cutAction.triggered.connect(self.text.cut)

        self.copyAction = QtWidgets.QAction(QtGui.QIcon('icons/copy.png'), 'Copy to clipboard', self)
        self.copyAction.setStatusTip('Copy text to clipboard')
        self.copyAction.setShortcut('Ctrl+C')
        self.copyAction.triggered.connect(self.text.copy)

        self.pasteAction = QtWidgets.QAction(QtGui.QIcon('icons/paste.png'), 'Paste from clipboard', self)
        self.pasteAction.setStatusTip('Paste text from clipboard')
        self.pasteAction.setShortcut('Ctrl+V')
        self.pasteAction.triggered.connect(self.text.paste)

        self.undoAction = QtWidgets.QAction(QtGui.QIcon('icons/undo.png'), 'Undo last action', self)
        self.undoAction.setStatusTip('Undo last action')
        self.undoAction.setShortcut('Ctrl+Z')
        self.undoAction.triggered.connect(self.text.undo)

        self.redoAction = QtWidgets.QAction(QtGui.QIcon('icons/redo.png'), 'Redo last undone thing', self)
        self.redoAction.setStatusTip('Redo last undone thing')
        self.redoAction.setShortcut('Ctrl+Y')
        self.redoAction.triggered.connect(self.text.redo)

        wordCountAction = QtWidgets.QAction(QtGui.QIcon('icons/count.png'), 'See word/symbol count', self)
        wordCountAction.setStatusTip('See word/symbol count')
        wordCountAction.setShortcut('Ctrl+W')
        wordCountAction.triggered.connect(self.wordCount)

        imageAction = QtWidgets.QAction(QtGui.QIcon('icons/image.png'), 'Insert image', self)
        imageAction.setStatusTip('Insert image')
        imageAction.setShortcut('Ctrl+Shift+I')
        imageAction.triggered.connect(self.insertImage)

        bulletAction = QtWidgets.QAction(QtGui.QIcon('icons/bullet.png'), 'Insert bullet List', self)
        bulletAction.setStatusTip('Insert bullet list')
        bulletAction.setShortcut('Ctrl+Shift+B')
        bulletAction.triggered.connect(self.bulletList)

        numberedAction = QtWidgets.QAction(QtGui.QIcon('icons/number.png'), 'Insert numbered List', self)
        numberedAction.setStatusTip('Insert numbered list')
        numberedAction.setShortcut('Ctrl+Shift+L')
        numberedAction.triggered.connect(self.numberList)

        self.toolbar = self.addToolBar('Options')

        self.toolbar.addAction(self.newAction)
        self.toolbar.addAction(self.openAction)
        self.toolbar.addAction(self.saveAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.printAction)
        self.toolbar.addAction(self.previewAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.cutAction)
        self.toolbar.addAction(self.copyAction)
        self.toolbar.addAction(self.pasteAction)
        self.toolbar.addAction(self.undoAction)
        self.toolbar.addAction(self.redoAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.findAction)
        self.toolbar.addAction(wordCountAction)
        self.toolbar.addAction(imageAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(bulletAction)
        self.toolbar.addAction(numberedAction)

        # Makes the next toolbar appear underneath this one
        self.addToolBarBreak()
Example #3
0
File: main.py Project: nwagu/pablo
 def _find(self):
     ff = find.Find(self)
     ff.show()
Example #4
0
    def initToolbar(self):
        self.newAction = QtWidgets.QAction(QtGui.QIcon("icons/new.png"), "New",
                                           self)
        self.newAction.setShortcut("Ctrl+N")
        self.newAction.setStatusTip("Create a new document from scratch.")
        self.newAction.triggered.connect(self.new)

        self.openAction = QtWidgets.QAction(QtGui.QIcon("icons/open.png"),
                                            "Open file", self)
        self.openAction.setStatusTip("Open existing document")
        self.openAction.setShortcut("Ctrl+O")
        self.openAction.triggered.connect(self.open)

        self.saveAction = QtWidgets.QAction(QtGui.QIcon("icons/save.png"),
                                            "Save", self)
        self.saveAction.setStatusTip("Save document")
        self.saveAction.setShortcut("Ctrl+S")
        self.saveAction.triggered.connect(self.save)

        self.printAction = QtWidgets.QAction(QtGui.QIcon("icons/print.png"),
                                             "Print document", self)
        self.printAction.setStatusTip("Print document")
        self.printAction.setShortcut("Ctrl+P")
        self.printAction.triggered.connect(self.printHandler)

        self.previewAction = QtWidgets.QAction(
            QtGui.QIcon("icons/preview.png"), "Page view", self)
        self.previewAction.setStatusTip("Preview page before printing")
        self.previewAction.setShortcut("Ctrl+Shift+P")
        self.previewAction.triggered.connect(self.preview)

        self.findAction = QtWidgets.QAction(QtGui.QIcon("icons/find.png"),
                                            "Find and replace", self)
        self.findAction.setStatusTip("Find and replace words in your document")
        self.findAction.setShortcut("Ctrl+F")
        self.findAction.triggered.connect(find.Find(self).show)

        self.cutAction = QtWidgets.QAction(QtGui.QIcon("icons/cut.png"),
                                           "Cut to clipboard", self)
        self.cutAction.setStatusTip("Delete and copy text to clipboard")
        self.cutAction.setShortcut("Ctrl+X")
        self.cutAction.triggered.connect(self.text.cut)

        self.copyAction = QtWidgets.QAction(QtGui.QIcon("icons/copy.png"),
                                            "Copy to clipboard", self)
        self.copyAction.setStatusTip("Copy text to clipboard")
        self.copyAction.setShortcut("Ctrl+C")
        self.copyAction.triggered.connect(self.text.copy)

        self.pasteAction = QtWidgets.QAction(QtGui.QIcon("icons/paste.png"),
                                             "Paste from clipboard", self)
        self.pasteAction.setStatusTip("Paste text from clipboard")
        self.pasteAction.setShortcut("Ctrl+V")
        self.pasteAction.triggered.connect(self.text.paste)

        self.undoAction = QtWidgets.QAction(QtGui.QIcon("icons/undo.png"),
                                            "Undo last action", self)
        self.undoAction.setStatusTip("Undo last action")
        self.undoAction.setShortcut("Ctrl+Z")
        self.undoAction.triggered.connect(self.text.undo)

        self.redoAction = QtWidgets.QAction(QtGui.QIcon("icons/redo.png"),
                                            "Redo last undone thing", self)
        self.redoAction.setStatusTip("Redo last undone thing")
        self.redoAction.setShortcut("Ctrl+Y")
        self.redoAction.triggered.connect(self.text.redo)

        dateTimeAction = QtWidgets.QAction(QtGui.QIcon("icons/calender.png"),
                                           "Insert current date/time", self)
        dateTimeAction.setStatusTip("Insert current date/time")
        dateTimeAction.setShortcut("Ctrl+D")
        dateTimeAction.triggered.connect(datetime.DateTime(self).show)

        wordCountAction = QtWidgets.QAction(QtGui.QIcon("icons/count.png"),
                                            "See word/symbol count", self)
        wordCountAction.setStatusTip("See word/symbol count")
        wordCountAction.setShortcut("Ctrl+W")
        wordCountAction.triggered.connect(self.wordCount)

        tableAction = QtWidgets.QAction(QtGui.QIcon("icons/table.png"),
                                        "Insert table", self)
        tableAction.setStatusTip("Insert table")
        tableAction.setShortcut("Ctrl+T")
        tableAction.triggered.connect(table.Table(self).show)

        imageAction = QtWidgets.QAction(QtGui.QIcon("icons/image.png"),
                                        "Insert image", self)
        imageAction.setStatusTip("Insert image")
        imageAction.setShortcut("Ctrl+Shift+I")
        imageAction.triggered.connect(self.insertImage)

        pasteimgAction = QtWidgets.QAction(QtGui.QIcon("icons/pasteimg.jpg"),
                                           "Insert Clipboard", self)
        pasteimgAction.setStatusTip("Insert image from Clipboard")
        pasteimgAction.setShortcut("Ctrl+Shift+I")
        pasteimgAction.triggered.connect(self.pasteImage)

        bulletAction = QtWidgets.QAction(QtGui.QIcon("icons/bullet.png"),
                                         "Insert bullet List", self)
        bulletAction.setStatusTip("Insert bullet list")
        bulletAction.setShortcut("Ctrl+Shift+B")
        bulletAction.triggered.connect(self.bulletList)

        numberedAction = QtWidgets.QAction(QtGui.QIcon("icons/number.png"),
                                           "Insert numbered List", self)
        numberedAction.setStatusTip("Insert numbered list")
        numberedAction.setShortcut("Ctrl+Shift+L")
        numberedAction.triggered.connect(self.numberList)

        self.toolbar = self.addToolBar("Options")

        self.toolbar.addAction(self.newAction)
        self.toolbar.addAction(self.openAction)
        self.toolbar.addAction(self.saveAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.printAction)
        self.toolbar.addAction(self.previewAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.cutAction)
        self.toolbar.addAction(self.copyAction)
        self.toolbar.addAction(self.pasteAction)
        self.toolbar.addAction(self.undoAction)
        self.toolbar.addAction(self.redoAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.findAction)
        self.toolbar.addAction(dateTimeAction)
        self.toolbar.addAction(wordCountAction)
        self.toolbar.addAction(tableAction)
        self.toolbar.addAction(imageAction)
        self.toolbar.addAction(pasteimgAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(bulletAction)
        self.toolbar.addAction(numberedAction)

        self.addToolBarBreak()
Example #5
0
    def initToolbar(self):

        self.newAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "new.png"),"New", self)
        self.newAction.setStatusTip("Create a new model description file.")
        self.newAction.setShortcut("Ctrl+N")
        self.newAction.triggered.connect(self.new)

        self.openAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "open.png"),"Open File", self)
        self.openAction.setStatusTip("Open an existing model description file.")
        self.openAction.setShortcut("Ctrl+O")
        self.openAction.triggered.connect(self.open)

        self.saveAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "save.png"),"Save File", self)
        self.saveAction.setStatusTip("Save model description file.")
        #self.saveAction.setShortcut("Ctrl+S")
        self.saveAction.triggered.connect(self.save)

        self.saveAsAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "save.png"),"Save File As", self)
        self.saveAsAction.setStatusTip("Save model description file As...")
        self.saveAsAction.setShortcut("Ctrl+S")
        self.saveAsAction.triggered.connect(self.saveAs)

        self.quitAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "icon.png"),"Quit", self)
        self.quitAction.setStatusTip("Leave the application.")
        self.quitAction.setShortcut("Ctrl+Q")
        self.quitAction.triggered.connect(self.quit)


        self.compileAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "2gen.png"),"Compile into Gen", self)
        self.compileAction.setStatusTip("Compile the model file into Gen DSP Code")
        self.compileAction.setShortcut("Ctrl+G")
        self.compileAction.triggered.connect(self.compile)

        self.faustCompileAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "2faust.png"),"Compile into Faust DSP", self)
        self.faustCompileAction.setStatusTip("Compile the model file into Faust DSP Code")
        self.faustCompileAction.setShortcut("Ctrl+D")
        self.faustCompileAction.triggered.connect(self.faustCompile)

        self.cutAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "cut.png"),"Cut to clipboard", self)
        self.cutAction.setStatusTip("Cut text into clipboard")
        self.cutAction.setShortcut("Ctrl+X")
        self.cutAction.triggered.connect(self.textEdit.cut)

        self.copyAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "copy.png"),"Copy to clipboard", self)
        self.copyAction.setStatusTip("Copy text to clipboard")
        self.copyAction.setShortcut("Ctrl+C")
        self.copyAction.triggered.connect(self.textEdit.copy)

        self.pasteAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "paste.png"), "Paste from clipboard", self)
        self.pasteAction.setStatusTip("Paste text from clipboard")
        self.pasteAction.setShortcut("Ctrl+V")
        self.pasteAction.triggered.connect(self.textEdit.paste)

        self.commentAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "comment.png"), "Comment Line / Selection", self)
        self.commentAction.setStatusTip("Comment line or selection")
        self.commentAction.setShortcut("Ctrl+/")
        self.commentAction.triggered.connect(self.comment)

        self.uncommentAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "uncomment.png"), "Uncomment Line / Selection", self)
        self.uncommentAction.setStatusTip("Uncomment line or selection")
        self.uncommentAction.setShortcut("Ctrl+/")
        self.uncommentAction.triggered.connect(self.uncomment)

        self.undoAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "undo.png"), "Undo last action", self)
        self.undoAction.setStatusTip("Undo last action")
        self.undoAction.setShortcut("Ctrl+Z")
        self.undoAction.triggered.connect(self.textEdit.undo)

        self.redoAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "redo.png"), "Redo last undone thing", self)
        self.redoAction.setStatusTip("Redo last undone thing")
        self.redoAction.setShortcut("Ctrl+Y")
        self.redoAction.triggered.connect(self.textEdit.redo)

        self.findAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "find.png"), "Find/Replace", self)
        self.findAction.setStatusTip("Find and replace elements in model script")
        self.findAction.setShortcut("Ctrl+F")
        self.findAction.triggered.connect(find.Find(self).show)

        self.genAction = QtWidgets.QAction(QtGui.QIcon(iconDir + "generate.png"), "Generate Structure", self)
        self.genAction.setStatusTip("Generate a structure")
        self.genAction.setShortcut("Ctrl+U")
        self.genAction.triggered.connect(createTopology.createTopo(self).show)

        self.toolbar = self.addToolBar("Options")

        self.toolbar.addAction(self.newAction)
        self.toolbar.addAction(self.openAction)
        self.toolbar.addAction(self.saveAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.undoAction)
        self.toolbar.addAction(self.redoAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.cutAction)
        self.toolbar.addAction(self.copyAction)
        self.toolbar.addAction(self.pasteAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.commentAction)
        self.toolbar.addAction(self.uncommentAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.findAction)
        self.toolbar.addAction(self.genAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.compileAction)
        self.toolbar.addAction(self.faustCompileAction)

        self.addToolBarBreak()
Example #6
0
    def initToolbar(self):

        self.newAction = QtWidgets.QAction(QtGui.QIcon("icons/new.png"), "New",
                                           self)
        self.newAction.setShortcut("Ctrl+N")
        self.newAction.setStatusTip("Create a new document from scratch.")
        self.newAction.triggered.connect(self.new)

        self.openAction = QtWidgets.QAction(QtGui.QIcon("icons/open.png"),
                                            "Open file", self)
        self.openAction.setStatusTip("Open existing document")
        self.openAction.setShortcut("Ctrl+O")
        self.openAction.triggered.connect(self.open)

        self.saveAction = QtWidgets.QAction(QtGui.QIcon("icons/save.png"),
                                            "Save", self)
        self.saveAction.setStatusTip("Save document")
        self.saveAction.setShortcut("Ctrl+S")
        self.saveAction.triggered.connect(self.save)

        self.saveAsAction = QtWidgets.QAction(QtGui.QIcon("icons/saveas.png"),
                                              "Save As", self)
        self.saveAsAction.setStatusTip("Save document as")
        self.saveAsAction.setShortcut("Ctrl+Shift+S")
        self.saveAsAction.triggered.connect(self.saveAs)

        self.printAction = QtWidgets.QAction(QtGui.QIcon("icons/print.png"),
                                             "Print document", self)
        self.printAction.setStatusTip("Print document")
        self.printAction.setShortcut("Ctrl+P")
        self.printAction.triggered.connect(self.printHandler)

        self.previewAction = QtWidgets.QAction(
            QtGui.QIcon("icons/preview.png"), "Page view", self)
        self.previewAction.setStatusTip("Preview page before printing")
        self.previewAction.setShortcut("Ctrl+Shift+P")
        self.previewAction.triggered.connect(self.preview)

        wordCountAction = QtWidgets.QAction(QtGui.QIcon("icons/count.png"),
                                            "See word/symbol count", self)
        wordCountAction.setStatusTip("See word/symbol count")
        wordCountAction.setShortcut("Ctrl+W")
        wordCountAction.triggered.connect(self.wordCount)

        self.findAction = QtWidgets.QAction(QtGui.QIcon("icons/find.png"),
                                            "Find and replace", self)
        self.findAction.setStatusTip("Find and replace words in your document")
        self.findAction.setShortcut("Ctrl+F")
        self.findAction.triggered.connect(find.Find(self).show)

        self.cutAction = QtWidgets.QAction(QtGui.QIcon("icons/cut.png"),
                                           "Cut to clipboard", self)
        self.cutAction.setStatusTip("Delete and copy text to clipboard")
        self.cutAction.setShortcut("Ctrl+X")
        self.cutAction.triggered.connect(self.text.cut)

        self.copyAction = QtWidgets.QAction(QtGui.QIcon("icons/copy.png"),
                                            "Copy to clipboard", self)
        self.copyAction.setStatusTip("Copy text to clipboard")
        self.copyAction.setShortcut("Ctrl+C")
        self.copyAction.triggered.connect(self.text.copy)

        self.pasteAction = QtWidgets.QAction(QtGui.QIcon("icons/paste.png"),
                                             "Paste from clipboard", self)
        self.pasteAction.setStatusTip("Paste text from clipboard")
        self.pasteAction.setShortcut("Ctrl+V")
        self.pasteAction.triggered.connect(self.text.paste)

        self.undoAction = QtWidgets.QAction(QtGui.QIcon("icons/undo.png"),
                                            "Undo last action", self)
        self.undoAction.setStatusTip("Undo last action")
        self.undoAction.setShortcut("Ctrl+Z")
        self.undoAction.triggered.connect(self.text.undo)

        self.redoAction = QtWidgets.QAction(QtGui.QIcon("icons/redo.png"),
                                            "Redo last undone thing", self)
        self.redoAction.setStatusTip("Redo last undone thing")
        self.redoAction.setShortcut("Ctrl+Y")
        self.redoAction.triggered.connect(self.text.redo)

        self.templateAction = QtWidgets.QAction(
            QtGui.QIcon("icons/template.png"), "Define template file", self)
        self.templateAction.setStatusTip(
            "Define a template file before a quick export, extension must match the destination type"
        )
        self.templateAction.triggered.connect(self.defineTemplate)

        self.optionAction = QtWidgets.QAction(QtGui.QIcon("icons/gear.png"),
                                              "Define export otions", self)
        self.optionAction.setStatusTip(
            "Define the export options : self-contained, toc...")
        self.optionAction.triggered.connect(self.setOptions)

        self.PDFExportAction = QtWidgets.QAction(QtGui.QIcon("icons/pdf.png"),
                                                 "Export as PDF file", self)
        self.PDFExportAction.setStatusTip("Export as PDF")
        self.PDFExportAction.triggered.connect(self.exportPDF)

        self.HTMLExportAction = QtWidgets.QAction(
            QtGui.QIcon("icons/html.png"), "Export as HTML file", self)
        self.HTMLExportAction.setStatusTip("Export as HTML")
        self.HTMLExportAction.triggered.connect(self.exportHTML)

        self.EpubExportAction = QtWidgets.QAction(
            QtGui.QIcon("icons/epub.png"), "Export as Epub file", self)
        self.EpubExportAction.setStatusTip("Export as Epub")
        self.EpubExportAction.triggered.connect(self.exportEpub)

        self.docxExportAction = QtWidgets.QAction(
            QtGui.QIcon("icons/word.png"), "Export as Docx file", self)
        self.docxExportAction.setStatusTip("Export as Docx")
        self.docxExportAction.triggered.connect(self.exportDocx)

        self.texExportAction = QtWidgets.QAction(
            QtGui.QIcon("icons/latex.png"), "Export as Tex file", self)
        self.texExportAction.setStatusTip("Export as Tex")
        self.texExportAction.triggered.connect(self.exportTex)

        self.toolbar = self.addToolBar("Options")

        self.toolbar.addAction(self.newAction)
        self.toolbar.addAction(self.openAction)
        self.toolbar.addAction(self.saveAction)
        self.toolbar.addAction(self.saveAsAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.printAction)
        self.toolbar.addAction(self.previewAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.cutAction)
        self.toolbar.addAction(self.copyAction)
        self.toolbar.addAction(self.pasteAction)
        self.toolbar.addAction(self.undoAction)
        self.toolbar.addAction(self.redoAction)

        self.toolbar.addSeparator()
        self.toolbar.addAction(wordCountAction)
        self.toolbar.addAction(self.findAction)

        self.toolbar.addSeparator()
        self.toolbar.addSeparator()

        self.toolbar.addAction(self.templateAction)
        self.toolbar.addAction(self.optionAction)
        self.toolbar.addAction(self.PDFExportAction)
        self.toolbar.addAction(self.HTMLExportAction)
        self.toolbar.addAction(self.EpubExportAction)
        self.toolbar.addAction(self.docxExportAction)
        self.toolbar.addAction(self.texExportAction)
        self.addToolBarBreak()
Example #7
0
    def initToolbar(self):

        # File Management Functions
        # (newAction, openAction, saveAction)
        self.newAction = QtGui.QAction(QtGui.QIcon("icons/new.png"), "New",
                                       self)
        self.newAction.setStatusTip("Create a new document from scratch.")
        self.newAction.setShortcut("Ctrl+N")
        self.newAction.triggered.connect(self.New)

        self.openAction = QtGui.QAction(QtGui.QIcon("icons/open.png"),
                                        "Open file", self)
        self.openAction.setStatusTip("Open existing document")
        self.openAction.setShortcut("Ctrl+O")
        self.openAction.triggered.connect(self.Open)

        self.saveAction = QtGui.QAction(QtGui.QIcon("icons/save.png"), "Save",
                                        self)
        self.saveAction.setStatusTip("Save document")
        self.saveAction.setShortcut("Ctrl+S")
        self.saveAction.triggered.connect(self.Save)

        # Printing Function (printAction, previewAction)
        self.printAction = QtGui.QAction(QtGui.QIcon("icons/print.png"),
                                         "Print document", self)
        self.printAction.setStatusTip("Print document")
        self.printAction.setShortcut("Ctrl+P")
        self.printAction.triggered.connect(self.Print)

        self.previewAction = QtGui.QAction(QtGui.QIcon("icons/preview.png"),
                                           "Page view", self)
        self.previewAction.setStatusTip("Preview page before printing")
        self.previewAction.setShortcut("Ctrl+Shift+P")
        self.previewAction.triggered.connect(self.Preview)

        # Copy/Paste , Undo/Redo functions
        self.cutAction = QtGui.QAction(QtGui.QIcon("icons/cut.png"),
                                       "Cut to clipboard", self)
        self.cutAction.setStatusTip("Delete and copy text to clipboard")
        self.cutAction.setShortcut("Ctrl+X")
        self.cutAction.triggered.connect(self.text.cut)

        self.copyAction = QtGui.QAction(QtGui.QIcon("icons/copy.png"),
                                        "Copy to clipboard", self)
        self.copyAction.setStatusTip("Copy text to clipboard")
        self.copyAction.setShortcut("Ctrl+C")
        self.copyAction.triggered.connect(self.text.copy)

        self.pasteAction = QtGui.QAction(QtGui.QIcon("icons/paste.png"),
                                         "Paste from clipboard", self)
        self.pasteAction.setStatusTip("Paste text from clipboard")
        self.pasteAction.setShortcut("Ctrl+V")
        self.pasteAction.triggered.connect(self.text.paste)

        self.undoAction = QtGui.QAction(QtGui.QIcon("icons/undo.png"),
                                        "Undo last action", self)
        self.undoAction.setStatusTip("Undo last action")
        self.undoAction.setShortcut("Ctrl+Z")
        self.undoAction.triggered.connect(self.text.undo)

        self.redoAction = QtGui.QAction(QtGui.QIcon("icons/redo.png"),
                                        "Redo last undone thing", self)
        self.redoAction.setStatusTip("Redo last undone thing")
        self.redoAction.setShortcut("Ctrl+Y")
        self.redoAction.triggered.connect(self.text.redo)

        self.findAction = QtGui.QAction(QtGui.QIcon("icons/find.png"),
                                        "Find and replace", self)
        self.findAction.setStatusTip("Find and replace words in your document")
        self.findAction.setShortcut("Ctrl+F")
        self.findAction.triggered.connect(find.Find(self).show)

        self.gitpush = QtGui.QAction(QtGui.QIcon("icons/git.ico"),
                                     "Upload to Github", self)
        self.gitpush.setStatusTip("Upload to GitHub")
        self.gitpush.setShortcut("Ctrl+G")
        self.gitpush.triggered.connect(gitpush.Gitpush(self).show)

        self.statusbarAction = QtGui.QAction("Toggle Status Bar", self)
        self.statusbarAction.triggered.connect(self.toggleStatusbar)

        self.fontsize = QtGui.QSpinBox(self)
        self.fontsize.setSuffix(" pt")
        self.fontsize.setValue(12)
        self.fontsize.valueChanged.connect(
            lambda size: self.changeFontSize(size))

        # Adding to toolbar
        self.toolbar = self.addToolBar("Options")

        self.toolbar.addAction(self.newAction)
        self.toolbar.addAction(self.openAction)
        self.toolbar.addAction(self.saveAction)
        self.toolbar.addAction(self.printAction)
        self.toolbar.addAction(self.previewAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.cutAction)
        self.toolbar.addAction(self.copyAction)
        self.toolbar.addAction(self.pasteAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.undoAction)
        self.toolbar.addAction(self.redoAction)
        self.toolbar.addAction(self.findAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.gitpush)

        self.toolbar.addSeparator()

        self.toolbar.addWidget(self.syntaxBox)
        self.toolbar.addSeparator()
        self.toolbar.addWidget(self.fontsize)
Example #8
0
    def initToolbar(self):

        self.newAction = QtGui.QAction(QtGui.QIcon("icons/new.png"), "New",
                                       self)
        self.newAction.setShortcut("Ctrl+N")
        self.newAction.setStatusTip("Create a new document from scratch.")
        self.newAction.triggered.connect(self.new)

        self.openAction = QtGui.QAction(QtGui.QIcon("icons/open.png"),
                                        "Open file", self)
        self.openAction.setStatusTip("Open existing document")
        self.openAction.setShortcut("Ctrl+O")
        self.openAction.triggered.connect(self.open)

        self.saveAction = QtGui.QAction(QtGui.QIcon("icons/save.png"), "Save",
                                        self)
        self.saveAction.setStatusTip("Save document")
        self.saveAction.setShortcut("Ctrl+S")
        self.saveAction.triggered.connect(self.save)

        self.convertAction = QtGui.QAction(
            QtGui.QIcon("icons/abbreviations.png"), "Replace abbreviations",
            self)
        self.convertAction.setStatusTip("Replace abbreviations")
        self.convertAction.setShortcut("Ctrl+I")
        self.convertAction.triggered.connect(
            abbreviations.Abbreviations(self).show)

        self.printAction = QtGui.QAction(QtGui.QIcon("icons/print.png"),
                                         "Print document", self)
        self.printAction.setStatusTip("Print document")
        self.printAction.setShortcut("Ctrl+P")
        self.printAction.triggered.connect(self.printHandler)

        self.previewAction = QtGui.QAction(QtGui.QIcon("icons/preview.png"),
                                           "Page view", self)
        self.previewAction.setStatusTip("Preview page before printing")
        self.previewAction.setShortcut("Ctrl+Shift+P")
        self.previewAction.triggered.connect(self.preview)

        self.findAction = QtGui.QAction(QtGui.QIcon("icons/find.png"),
                                        "Find and replace", self)
        self.findAction.setStatusTip("Find and replace words in your document")
        self.findAction.setShortcut("Ctrl+F")
        self.findAction.triggered.connect(find.Find(self).show)

        self.undoAction = QtGui.QAction(QtGui.QIcon("icons/undo.png"),
                                        "Undo last action", self)
        self.undoAction.setStatusTip("Undo last action")
        self.undoAction.setShortcut("Ctrl+Z")
        self.undoAction.triggered.connect(self.text.undo)

        self.redoAction = QtGui.QAction(QtGui.QIcon("icons/redo.png"),
                                        "Redo last undone thing", self)
        self.redoAction.setStatusTip("Redo last undone thing")
        self.redoAction.setShortcut("Ctrl+Y")
        self.redoAction.triggered.connect(self.text.redo)

        tableAction = QtGui.QAction(QtGui.QIcon("icons/table.png"),
                                    "Insert table", self)
        tableAction.setStatusTip("Insert table")
        tableAction.setShortcut("Ctrl+T")
        tableAction.triggered.connect(table.Table(self).show)

        imageAction = QtGui.QAction(QtGui.QIcon("icons/image.png"),
                                    "Insert image", self)
        imageAction.setStatusTip("Insert image")
        imageAction.setShortcut("Ctrl+Shift+I")
        imageAction.triggered.connect(self.insertImage)

        bulletAction = QtGui.QAction(QtGui.QIcon("icons/bullet.png"),
                                     "Insert bullet List", self)
        bulletAction.setStatusTip("Insert bullet list")
        bulletAction.setShortcut("Ctrl+Shift+B")
        bulletAction.triggered.connect(self.bulletList)

        numberedAction = QtGui.QAction(QtGui.QIcon("icons/number.png"),
                                       "Insert numbered List", self)
        numberedAction.setStatusTip("Insert numbered list")
        numberedAction.setShortcut("Ctrl+Shift+L")
        numberedAction.triggered.connect(self.numberList)

        fontBox = QtGui.QFontComboBox(self)
        fontBox.currentFontChanged.connect(
            lambda font: self.text.setCurrentFont(font))

        fontSize = QtGui.QSpinBox(self)

        # Will display " pt" after each value
        fontSize.setSuffix(" pt")

        fontSize.valueChanged.connect(
            lambda size: self.text.setFontPointSize(size))

        fontSize.setValue(14)

        fontColor = QtGui.QAction(QtGui.QIcon("icons/font-color.png"),
                                  "Change font color", self)
        fontColor.triggered.connect(self.fontColorChanged)

        boldAction = QtGui.QAction(QtGui.QIcon("icons/bold.png"), "Bold", self)
        boldAction.triggered.connect(self.bold)

        italicAction = QtGui.QAction(QtGui.QIcon("icons/italic.png"), "Italic",
                                     self)
        italicAction.triggered.connect(self.italic)

        underlAction = QtGui.QAction(QtGui.QIcon("icons/underline.png"),
                                     "Underline", self)
        underlAction.triggered.connect(self.underline)

        strikeAction = QtGui.QAction(QtGui.QIcon("icons/strike.png"),
                                     "Strike-out", self)
        strikeAction.triggered.connect(self.strike)

        superAction = QtGui.QAction(QtGui.QIcon("icons/superscript.png"),
                                    "Superscript", self)
        superAction.triggered.connect(self.superScript)

        subAction = QtGui.QAction(QtGui.QIcon("icons/subscript.png"),
                                  "Subscript", self)
        subAction.triggered.connect(self.subScript)

        alignLeft = QtGui.QAction(QtGui.QIcon("icons/align-left.png"),
                                  "Align left", self)
        alignLeft.triggered.connect(self.alignLeft)

        alignCenter = QtGui.QAction(QtGui.QIcon("icons/align-center.png"),
                                    "Align center", self)
        alignCenter.triggered.connect(self.alignCenter)

        alignRight = QtGui.QAction(QtGui.QIcon("icons/align-right.png"),
                                   "Align right", self)
        alignRight.triggered.connect(self.alignRight)

        alignJustify = QtGui.QAction(QtGui.QIcon("icons/align-justify.png"),
                                     "Align justify", self)
        alignJustify.triggered.connect(self.alignJustify)

        backColor = QtGui.QAction(QtGui.QIcon("icons/highlight.png"),
                                  "Change background color", self)
        backColor.triggered.connect(self.highlight)

        self.toolbar = self.addToolBar("Options")

        self.toolbar.addWidget(fontBox)
        self.toolbar.addWidget(fontSize)

        self.toolbar.addSeparator()

        self.toolbar.addAction(boldAction)
        self.toolbar.addAction(italicAction)
        self.toolbar.addAction(underlAction)
        self.toolbar.addAction(strikeAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(fontColor)
        self.toolbar.addAction(backColor)

        self.toolbar.addSeparator()

        self.toolbar.addAction(alignLeft)
        self.toolbar.addAction(alignCenter)
        self.toolbar.addAction(alignRight)
        self.toolbar.addAction(alignJustify)

        self.toolbar.addSeparator()

        self.toolbar.addAction(superAction)
        self.toolbar.addAction(subAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(self.findAction)
        self.toolbar.addAction(self.convertAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(tableAction)
        self.toolbar.addAction(imageAction)

        self.toolbar.addSeparator()

        self.toolbar.addAction(bulletAction)
        self.toolbar.addAction(numberedAction)