コード例 #1
0
def getEditor():
    editor = QsciScintilla()
    lexer = QsciLexerYAML()
    editor.setLexer(lexer)
    font = getFont()
    # lexer.setDefaultFont(font)
    lexer.setFont(font)
    settings = QSettings()
    lexer.readSettings(settings)
    print(settings.allKeys())
    lexer.setDefaultPaper(QColor('#252721'))
    for i in range(10):
        lexer.setPaper(QColor('#252721'), i)
        lexer.setColor(QColor('#f8f8f2'), i)
        print(lexer.color(i).name())
    lexer.setColor(QColor('#e6db74'), 0)  # foreground (yellow)
    lexer.setColor(QColor('#75715e'), 1)  # comment (gray)
    lexer.setColor(QColor('#f92672'), 2)  # identifier (red)
    lexer.setColor(QColor('#ae81ff'), 3)  # keyword (purple)
    lexer.setColor(QColor('#ae81ff'), 4)  # number (purple)
    lexer.setColor(QColor('#ae81ff'), 5)  # reference (purple)
    lexer.setColor(QColor('#ae81ff'), 6)  # documentdelimiter (purple)
    lexer.setColor(QColor('#ae81ff'), 7)  # text block marker (purple)
    lexer.setColor(QColor('#f92672'), 8)  # syntax error marker (red)
    lexer.setColor(QColor('#f92672'), 9)  # operator (red)
    # editor.setFont(font)
    # editor.setMarginsFont(font)
    editor.setCaretForegroundColor(QColor('#f8f8f0'))
    editor.setMarginWidth(0, getMarginWidth(font))
    editor.setMarginWidth(1, 0)
    editor.setMarginLineNumbers(0, True)
    editor.setMarginsBackgroundColor(QColor('#252721'))
    editor.setMarginsForegroundColor(QColor('#f8f8f2'))
    editor.setExtraAscent(3)
    editor.setTabWidth(4)
    editor.setMinimumSize(600, 450)
    return editor
コード例 #2
0
class CustomMainWindow(QMainWindow):
    def __init__(self):
        super(CustomMainWindow, self).__init__()

        # Window setup
        # --------------

        # 1. Define the geometry of the main window
        self.setGeometry(300, 300, 800, 400)
        self.setWindowTitle("QScintilla Test")

        # 2. Create frame and layout
        self.__frm = QFrame(self)
        self.__frm.setStyleSheet("QWidget { background-color: #ffeaeaea }")
        self.__lyt = QVBoxLayout()
        self.__frm.setLayout(self.__lyt)
        self.setCentralWidget(self.__frm)
        self.__myFont = QFont()
        self.__myFont.setPointSize(14)

        # 3. Place a button
        self.__btn = QPushButton("Qsci")
        self.__btn.setFixedWidth(50)
        self.__btn.setFixedHeight(50)
        self.__btn.clicked.connect(self.__btn_action)
        self.__btn.setFont(self.__myFont)
        self.__lyt.addWidget(self.__btn)

        # QScintilla editor setup
        # ------------------------

        # ! Make instance of QsciScintilla class!
        self.__editor = QsciScintilla()
        self.__editor.setText("Hello\n")
        self.__editor.append("world \n")
        self.__editor.setLexer(None)
        self.__editor.setUtf8(True)  # Set encoding to UTF-8
        self.__editor.setFont(self.__myFont)  # Will be overridden by lexer!

        #simple editor options

        self.__editor.setEolVisibility(False) #sets the end of each line with an EOL character
        self.__editor.setIndentationsUseTabs(False) #determines whether indent uses tabs or whitespace char.
        self.__editor.setTabWidth(4)
        self.__editor.setIndentationGuides(True)
        self.__editor.setTabIndents(True)
        self.__editor.setAutoIndent(True)
        self.__editor.setCaretForegroundColor(QColor("#ff0000ff"))
        self.__editor.setCaretLineVisible(True)
        self.__editor.setCaretLineBackgroundColor(QColor("#1fff0000"))
        self.__editor.setCaretWidth(5)

        #Margin SetUp.
        self.__editor.setMarginType(3, self.__editor.NumberMargin)
        self.__editor.setMarginsForegroundColor(QColor("#ff888888"))
        # self.__editor.setMarginType(2, QsciScintilla.TextMargin)
        # Symbol Margin
        sym_0 = QImage("icons/sym_0.png").scaled(QSize(16, 16))
        sym_1 = QImage("icons/sym_1.png").scaled(QSize(16, 16))
        sym_2 = QImage("icons/sym_2.png").scaled(QSize(16, 16))
        sym_3 = QImage("icons/sym_3.png").scaled(QSize(16, 16))
        sym_4 = self.__editor.Circle
        self.__editor.markerDefine(sym_0, 0)
        self.__editor.markerDefine(sym_1, 1)
        self.__editor.markerDefine(sym_2, 2)
        self.__editor.markerDefine(sym_3, 3)
        self.__editor.markerDefine(sym_4, 4)
        self.__editor.setMarginType(3, self.__editor.SymbolMargin)
        # self.__editor.setMarginType(2, QsciScintilla.SymbolMarginDefaultBackgroundColor)
        # self.__editor.setMarginType(3, QsciScintilla.SymbolMarginDefaultForegroundColor)
        self.__editor.setMarginWidth(1, '00000')
        self.__editor.setMarginMarkerMask(1, 0b1111)
        self.__editor.setMarginMarkerMask(2, 0b1111)
        self.__editor.markerAdd(3, 2)
        # Display a few symbols, and keep their handles stored
        self.__editor.markerAdd(0, 0)   # Green dot on line 0+1
        self.__editor.markerAdd(4, 0)   # Green dot on line 4+1
        self.__editor.markerAdd(5, 0)   # Green dot on line 5+1
        self.__editor.markerAdd(8, 3)   # Red arrow on line 8+1
        self.__editor.markerAdd(9, 2)   # Red dot on line 9+1

        self.__editor.setFolding(self.__editor.BoxedFoldStyle, 4)
        self.__editor.SendScintilla(self.__editor.SCI_SETMULTIPLESELECTION, True)
        self.__editor.SendScintilla(self.__editor.SCI_SETMULTIPASTE, 1)
        self.__editor.SendScintilla(self.__editor.SCI_SETADDITIONALSELECTIONTYPING, True)
        self.__editor.SendScintilla(self.__editor.SCI_SETINDENTATIONGUIDES, self.__editor.SC_IV_REAL);
        self.__editor.SendScintilla(self.__editor.SCI_SETTABWIDTH, 4)

        # self.__editor.setMarginsBackgroundColor(QColor("#ff0000ff"))
        self.__editor.setWrapMode(QsciScintilla.WrapWord)
        self.__editor.setWrapIndentMode(QsciScintilla.WrapIndentIndented)

        # available wrap modes: 
        # QsciScintilla.WrapNone, WrapWord, WrapCharacter, WrapWhitespace
        self.__editor.setWrapVisualFlags(
            QsciScintilla.WrapFlagByText,
            startFlag=QsciScintilla.WrapFlagByText,
            indent=4)
        # setWrapVisualFlags(endFlag, startFlag, indent)
        # see: readMe
        self.__editor.setWrapIndentMode(QsciScintilla.WrapIndentIndented)
        self.__editor.textChanged.connect(self.text_changed) #signal typing

        # ! Add editor to layout !
        self.__lyt.addWidget(self.__editor)

        self.show()

    ''''''

    def __btn_action(self):
        self.__editor.append('Voila You just clicked the QSci button! \n')
        print("Hello World!")

    def text_changed(self):
        print({self.__editor.text()})
    ''''''
コード例 #3
0
class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Untitled")
        icon = os.path.join(BASE_DIR, 'ide/Icon.ico')
        self.setWindowIcon(QIcon(icon))
        self.saveLoad = SaveLoad()
        self.fileName = None
        self.setupUI()

    def setupUI(self):
        centralWidget = QWidget(self)
        layout = QHBoxLayout(centralWidget)
        self.fileSysView = QTreeView(centralWidget)
        self.setupFileSystemViewer()
        self.editor = QsciScintilla(centralWidget)
        self.setupEditor()
        layout.addWidget(self.fileSysView, 1)
        layout.addWidget(self.editor, 3)
        self.setCentralWidget(centralWidget)
        self.setMinimumSize(700, 500)
        self.defaultMenuBar = QMenuBar(self)
        self.setupMenus()
        self.setMenuBar(self.defaultMenuBar)
        self.show()

    def setupEditor(self):
        self.editor.setFont(QFont("Times New Roman", 12))
        self.editor.setMargins(2)
        self.editor.setMarginType(0, QsciScintilla.NumberMargin)
        self.editor.setMarginType(1, QsciScintilla.SymbolMargin)
        self.editor.setMarginWidth(0, "000")
        self.editor.setMarginWidth(1, "00")
        self.editor.markerDefine(QsciScintilla.RightTriangle, 1)
        if system() == "Windows":
            self.editor.setEolMode(QsciScintilla.EolWindows)
        elif system() == "Linux":
            self.editor.setEolMode(QsciScintilla.EolUnix)
        elif system() == "Mac":
            self.editor.setEolMode(QsciScintilla.EolMac)
        else:
            print("Using Windows EOL")
            self.editor.setEolMode(QsciScintilla.EolWindows)
        self.editor.setBraceMatching(QsciScintilla.SloppyBraceMatch)
        self.editor.setIndentationsUseTabs(True)
        self.editor.setTabWidth(4)
        self.editor.setIndentationGuides(True)
        self.editor.setTabIndents(True)
        self.editor.setAutoIndent(True)
        self.editor.setCaretForegroundColor(QColor("#ff11214b"))
        self.editor.setCaretLineVisible(True)
        self.editor.setCaretLineBackgroundColor(QColor("#1f0000ff"))
        self.editor.setUtf8(True)
        self.editor.setMarginSensitivity(1, True)
        self.editor.marginClicked.connect(self.margin_clicked)
        self.editor.marginRightClicked.connect(self.margin_right_clicked)
        self.lexer = QsciLexerPython()
        self.lexer.setFont(QFont("Times New Roman", 12))
        self.editor.setLexer(self.lexer)
        self.editor.textChanged.connect(self.fileChanged)

    def setupFileSystemViewer(self):
        model = QFileSystemModel()
        model.setRootPath("/")
        self.fileSysView.setModel(model)
        self.fileSysView.hideColumn(1)
        self.fileSysView.hideColumn(2)
        self.fileSysView.hideColumn(3)
        self.fileSysView.doubleClicked.connect(self.openFile)

    def setupMenus(self):
        fileMenu = QMenu(self.defaultMenuBar)
        fileMenu.setTitle("File")
        editMenu = QMenu(self.defaultMenuBar)
        editMenu.setTitle("Edit")
        viewMenu = QMenu(self.defaultMenuBar)
        viewMenu.setTitle("View")
        runMenu = QMenu(self.defaultMenuBar)
        runMenu.setTitle("Run")
        settingsMenu = QMenu(self.defaultMenuBar)
        settingsMenu.setTitle("Settings")
        self.actionNew = QAction(self)
        self.actionNew.setText("New")
        self.actionNew.setShortcut("Ctrl+N")
        self.actionOpen = QAction(self)
        self.actionOpen.setText("Open")
        self.actionOpen.setShortcut("Ctrl+O")
        self.actionSave = QAction(self)
        self.actionSave.setText("Save")
        self.actionSave.setShortcut("Ctrl+S")
        self.actionSaveAs = QAction(self)
        self.actionSaveAs.setText("Save As")
        self.actionSaveAs.setShortcut("Ctrl+Shift+S")
        self.actionExit = QAction(self)
        self.actionExit.setText("Exit")
        self.actionExit.setShortcut("Alt+X")
        self.actionUndo = QAction(self)
        self.actionUndo.setText("Undo")
        self.actionUndo.setShortcut("Ctrl+Z")
        self.actionRedo = QAction(self)
        self.actionRedo.setText("Redo")
        self.actionRedo.setShortcut("Ctrl+Shift+Z")
        self.actionSelectAll = QAction(self)
        self.actionSelectAll.setText("Select all")
        self.actionSelectAll.setShortcut("Ctrl+A")
        self.actionCut = QAction(self)
        self.actionCut.setText("Cut")
        self.actionCut.setShortcut("Ctrl+X")
        self.actionCopy = QAction(self)
        self.actionCopy.setText("Copy")
        self.actionCopy.setShortcut("Ctrl+C")
        self.actionPaste = QAction(self)
        self.actionPaste.setText("Paste")
        self.actionPaste.setShortcut("Ctrl+V")
        self.actionFind = QAction(self)
        self.actionFind.setText("Find")
        self.actionFind.setShortcut("Ctrl+F")
        self.actionReplace = QAction(self)
        self.actionReplace.setText("Replace")
        self.actionReplace.setShortcut("Ctrl+H")
        self.actionRun = QAction(self)
        self.actionRun.setText("Run")
        self.actionRun.setShortcut("F5")
        self.actionRunCustom = QAction(self)
        self.actionRunCustom.setText("Run Customized")
        self.actionRunCustom.setShortcut("Shift+F5")
        self.actionShell = QAction(self)
        self.actionShell.setText("Python shell")
        self.actionShell.setShortcut("Alt+S")
        self.actionFont = QAction(self)
        self.actionFont.setText("Font")
        self.actionEncoding = QAction(self)
        self.actionEncoding.setText("Encoding")
        fileMenu.addAction(self.actionNew)
        fileMenu.addAction(self.actionOpen)
        fileMenu.addAction(self.actionSave)
        fileMenu.addAction(self.actionSaveAs)
        fileMenu.addSeparator()
        fileMenu.addAction(self.actionExit)
        editMenu.addAction(self.actionUndo)
        editMenu.addAction(self.actionRedo)
        editMenu.addSeparator()
        editMenu.addAction(self.actionSelectAll)
        editMenu.addSeparator()
        editMenu.addAction(self.actionCut)
        editMenu.addAction(self.actionCopy)
        editMenu.addAction(self.actionPaste)
        viewMenu.addAction(self.actionFind)
        viewMenu.addAction(self.actionReplace)
        runMenu.addAction(self.actionRun)
        runMenu.addAction(self.actionRunCustom)
        runMenu.addAction(self.actionShell)
        settingsMenu.addAction(self.actionFont)
        settingsMenu.addAction(self.actionEncoding)
        self.defaultMenuBar.addAction(fileMenu.menuAction())
        self.defaultMenuBar.addAction(editMenu.menuAction())
        self.defaultMenuBar.addAction(viewMenu.menuAction())
        self.defaultMenuBar.addAction(runMenu.menuAction())
        self.defaultMenuBar.addAction(settingsMenu.menuAction())
        self.actionNew.triggered.connect(self.new)
        self.actionOpen.triggered.connect(self.open)
        self.actionSave.triggered.connect(self.save)
        self.actionSaveAs.triggered.connect(self.saveAs)
        self.actionExit.triggered.connect(self.close)
        self.actionUndo.triggered.connect(self.editor.undo)
        self.actionRedo.triggered.connect(self.editor.redo)
        self.actionSelectAll.triggered.connect(
            lambda: self.editor.selectAll(True))
        self.actionCut.triggered.connect(self.editor.cut)
        self.actionCopy.triggered.connect(self.editor.copy)
        self.actionPaste.triggered.connect(self.editor.paste)
        self.actionFind.triggered.connect(self.find)
        self.actionReplace.triggered.connect(self.replace)
        self.actionRun.triggered.connect(self.run)
        self.actionRunCustom.triggered.connect(self.runCustom)
        self.actionShell.triggered.connect(self.shell)
        self.actionFont.triggered.connect(self.Font)

    def margin_clicked(self, margin_nr, line_nr, state):
        self.editor.markerAdd(line_nr, margin_nr)

    def margin_right_clicked(self, margin_nr, line_nr, state):
        self.editor.markerDelete(line_nr, margin_nr)

    def new(self):
        if self.windowTitle().endswith("*"):
            if (Dialogs().Question(
                    self, "Do you want to save your file?") == "accept"):
                if self.filename is None:
                    self.saveAs()
                else:
                    self.save()
        self.editor.setText("")
        self.setWindowTitle("Untitled")

    def open(self):
        if self.windowTitle().endswith("*"):
            if (Dialogs().Question(
                    self, "Do you want to save your file?") == "accept"):
                if self.filename is None:
                    self.saveAs()
                else:
                    self.save()
        filename = self.saveLoad.OpenDialog()
        data = Open(filename)
        if data is not None:
            self.editor.setText(data)
            self.setWindowTitle(filename)
            self.filename = filename

    def save(self):
        if self.filename is None:
            self.saveAs()
        else:
            returnval = Save(self.editor.text(), self.filename)
            if (returnval):
                Dialogs().Message(self, "File saved successfully")
                self.setWindowTitle(self.filename)
            else:
                Dialogs().Error(self, "File could not be saved")

    def saveAs(self):
        self.filename = self.saveLoad.SaveDialog()
        returnval = Save(self.editor.text(), self.filename)
        if (returnval):
            Dialogs().Message(self, "File saved successfully")
            self.setWindowTitle(self.filename)
        else:
            Dialogs().Error(self, "File could not be saved")

    def run(self):
        if self.filename is None:
            self.saveAs()
        Runfile(self.filename)

    def runCustom(self):
        if self.filename is None:
            self.saveAs()
        if self.filename != "":
            print(len(self.filename))
            option, ok = QInputDialog().getText(
                self, "Customized run", "Enter parameters for sys.argv",
                QLineEdit.Normal, " ")
            if ok:
                Runfile(self.filename, option)

    def shell(self):
        Shell()

    def Font(self):
        font, ok = QFontDialog.getFont()
        if ok:
            self.editor.setFont(font)
            self.lexer.setFont(font)
            self.editor.setLexer(self.lexer)

    def openFile(self, signal):
        fileName = self.fileSysView.model().filePath(signal)
        if fileName.endswith("py") or fileName.endswith("pyw"):
            if self.windowTitle().endswith("*"):
                if Dialogs().Question(
                        self, "Do you want to save your file?") == "accept":
                    if self.filename is None:
                        self.saveAs()
                    else:
                        self.save()
            data = Open(fileName)
            if data is not None:
                self.editor.setText(data)
                self.setWindowTitle(fileName)
                self.filename = fileName

    def fileChanged(self):
        title = self.windowTitle()
        if not (title.endswith("*")):
            self.setWindowTitle(title + " *")

    def replace(self):
        replaceObj = replaceDialog(self, self.editor)

    def find(self):
        findObj = findDialog(self, self.editor)
コード例 #4
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("Proyecto")
        MainWindow.resize(1074, 588)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.btn_abrir = QtWidgets.QPushButton(self.centralwidget)
        self.btn_abrir.setGeometry(QtCore.QRect(970, 20, 61, 41))
        self.btn_abrir.setObjectName("btn_abrir")
        self.btn_guardar = QtWidgets.QPushButton(self.centralwidget)
        self.btn_guardar.setGeometry(QtCore.QRect(970, 70, 61, 41))
        self.btn_guardar.setObjectName("btn_guardar")
        self.btn_guardar_como = QtWidgets.QPushButton(self.centralwidget)
        self.btn_guardar_como.setGeometry(QtCore.QRect(970, 120, 61, 41))
        self.btn_guardar_como.setObjectName("btn_guardar_como")
        self.btn_ejecutar = QtWidgets.QPushButton(self.centralwidget)
        self.btn_ejecutar.setGeometry(QtCore.QRect(960, 220, 81, 41))
        self.btn_ejecutar.setObjectName("btn_ejecutar")
        self.btn_debug = QtWidgets.QPushButton(self.centralwidget)
        self.btn_debug.setGeometry(QtCore.QRect(970, 320, 61, 41))
        self.btn_debug.setObjectName("btn_debug")
        self.btn_siguiente_paso = QtWidgets.QPushButton(self.centralwidget)
        self.btn_siguiente_paso.setGeometry(QtCore.QRect(970, 370, 61, 41))
        self.btn_siguiente_paso.setObjectName("btn_siguiente_paso")
        self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
        self.tabWidget.setGeometry(QtCore.QRect(0, 10, 941, 551))
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.txt_consola = QtWidgets.QTextEdit(self.tab)
        self.txt_consola.setGeometry(QtCore.QRect(10, 410, 511, 101))
        self.txt_consola.setObjectName("txt_consola")
        self.tabWidget_4 = QtWidgets.QTabWidget(self.tab)
        self.tabWidget_4.setGeometry(QtCore.QRect(0, 0, 531, 391))
        self.tabWidget_4.setObjectName("tabWidget_4")
        self.tab_8 = QtWidgets.QWidget()
        self.tab_8.setObjectName("tab_8")
        self.tabWidget_3 = QtWidgets.QTabWidget(self.tab_8)
        self.tabWidget_3.setGeometry(QtCore.QRect(0, 0, 521, 361))
        self.tabWidget_3.setObjectName("tabWidget_3")
        self.tab_10 = QtWidgets.QWidget()
        self.tab_10.setObjectName("tab_10")
        self.frame_txt_entrada = QtWidgets.QFrame(self.tab_10)
        self.frame_txt_entrada.setGeometry(QtCore.QRect(10, 10, 501, 321))
        self.frame_txt_entrada.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_txt_entrada.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_txt_entrada.setObjectName("frame_txt_entrada")
        self.tabWidget_3.addTab(self.tab_10, "")
        self.tab_11 = QtWidgets.QWidget()
        self.tab_11.setObjectName("tab_11")
        self.frame_txt_entrada_sin_optimizar = QtWidgets.QFrame(self.tab_11)
        self.frame_txt_entrada_sin_optimizar.setGeometry(
            QtCore.QRect(10, 10, 501, 321))
        self.frame_txt_entrada_sin_optimizar.setFrameShape(
            QtWidgets.QFrame.StyledPanel)
        self.frame_txt_entrada_sin_optimizar.setFrameShadow(
            QtWidgets.QFrame.Raised)
        self.frame_txt_entrada_sin_optimizar.setObjectName(
            "frame_txt_entrada_sin_optimizar")
        self.tabWidget_3.addTab(self.tab_11, "")
        self.tabWidget_4.addTab(self.tab_8, "")
        self.tabWidget_2 = QtWidgets.QTabWidget(self.tab)
        self.tabWidget_2.setGeometry(QtCore.QRect(540, 20, 391, 491))
        self.tabWidget_2.setObjectName("tabWidget_2")
        self.tab_12 = QtWidgets.QWidget()
        self.tab_12.setObjectName("tab_12")
        self.frame_txt_minor_c = QtWidgets.QFrame(self.tab_12)
        self.frame_txt_minor_c.setGeometry(QtCore.QRect(10, 10, 361, 441))
        self.frame_txt_minor_c.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_txt_minor_c.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_txt_minor_c.setObjectName("frame_txt_minor_c")
        self.tabWidget_2.addTab(self.tab_12, "")
        self.tab_5 = QtWidgets.QWidget()
        self.tab_5.setObjectName("tab_5")
        self.scrollArea_2 = QtWidgets.QScrollArea(self.tab_5)
        self.scrollArea_2.setGeometry(QtCore.QRect(10, 10, 361, 441))
        self.scrollArea_2.setWidgetResizable(True)
        self.scrollArea_2.setObjectName("scrollArea_2")
        self.scrollAreaWidgetContents_2 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_2.setGeometry(
            QtCore.QRect(0, 0, 518, 422))
        self.scrollAreaWidgetContents_2.setObjectName(
            "scrollAreaWidgetContents_2")
        self.horizontalLayout = QtWidgets.QHBoxLayout(
            self.scrollAreaWidgetContents_2)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.treeView = QtWidgets.QTreeView(self.scrollAreaWidgetContents_2)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.treeView.sizePolicy().hasHeightForWidth())
        self.treeView.setSizePolicy(sizePolicy)
        self.treeView.setMinimumSize(QtCore.QSize(500, 0))
        self.treeView.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.treeView.setAnimated(True)
        self.treeView.setObjectName("treeView")
        self.horizontalLayout.addWidget(self.treeView)
        self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_2)
        self.tabWidget_2.addTab(self.tab_5, "")
        self.tabWidget.addTab(self.tab, "")
        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.scrollArea_3 = QtWidgets.QScrollArea(self.tab_2)
        self.scrollArea_3.setGeometry(QtCore.QRect(10, 10, 681, 411))
        self.scrollArea_3.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.scrollArea_3.setWidgetResizable(True)
        self.scrollArea_3.setObjectName("scrollArea_3")
        self.scrollAreaWidgetContents_3 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_3.setGeometry(
            QtCore.QRect(0, 0, 679, 409))
        self.scrollAreaWidgetContents_3.setObjectName(
            "scrollAreaWidgetContents_3")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(
            self.scrollAreaWidgetContents_3)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.lbl_graphviz = QtWidgets.QLabel(self.scrollAreaWidgetContents_3)
        self.lbl_graphviz.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.lbl_graphviz.setFrameShape(QtWidgets.QFrame.Panel)
        self.lbl_graphviz.setText("")
        self.lbl_graphviz.setScaledContents(False)
        self.lbl_graphviz.setObjectName("lbl_graphviz")
        self.verticalLayout_2.addWidget(self.lbl_graphviz)
        self.scrollArea_3.setWidget(self.scrollAreaWidgetContents_3)
        self.tabWidget.addTab(self.tab_2, "")
        self.tab_3 = QtWidgets.QWidget()
        self.tab_3.setObjectName("tab_3")
        self.scrollArea = QtWidgets.QScrollArea(self.tab_3)
        self.scrollArea.setGeometry(QtCore.QRect(10, 10, 681, 411))
        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setObjectName("scrollArea")
        self.scrollAreaWidgetContents = QtWidgets.QWidget()
        self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 679, 409))
        self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
        self.tab_reporte = QtWidgets.QTabWidget(self.scrollAreaWidgetContents)
        self.tab_reporte.setGeometry(QtCore.QRect(20, 10, 661, 381))
        self.tab_reporte.setObjectName("tab_reporte")
        self.tab_4 = QtWidgets.QWidget()
        self.tab_4.setObjectName("tab_4")
        self.scrollArea_4 = QtWidgets.QScrollArea(self.tab_4)
        self.scrollArea_4.setGeometry(QtCore.QRect(0, 10, 641, 341))
        self.scrollArea_4.setWidgetResizable(True)
        self.scrollArea_4.setObjectName("scrollArea_4")
        self.scrollAreaWidgetContents_4 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_4.setGeometry(
            QtCore.QRect(0, 0, 639, 339))
        self.scrollAreaWidgetContents_4.setObjectName(
            "scrollAreaWidgetContents_4")
        self.verticalLayout = QtWidgets.QVBoxLayout(
            self.scrollAreaWidgetContents_4)
        self.verticalLayout.setObjectName("verticalLayout")
        self.tabla_etiqueta = QtWidgets.QTableWidget(
            self.scrollAreaWidgetContents_4)
        self.tabla_etiqueta.setObjectName("tabla_etiqueta")
        self.tabla_etiqueta.setColumnCount(0)
        self.tabla_etiqueta.setRowCount(0)
        self.verticalLayout.addWidget(self.tabla_etiqueta)
        self.scrollArea_4.setWidget(self.scrollAreaWidgetContents_4)
        self.tab_reporte.addTab(self.tab_4, "")
        self.tab_6 = QtWidgets.QWidget()
        self.tab_6.setObjectName("tab_6")
        self.scrollArea_5 = QtWidgets.QScrollArea(self.tab_6)
        self.scrollArea_5.setGeometry(QtCore.QRect(0, 10, 641, 341))
        self.scrollArea_5.setWidgetResizable(True)
        self.scrollArea_5.setObjectName("scrollArea_5")
        self.scrollAreaWidgetContents_5 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_5.setGeometry(
            QtCore.QRect(0, 0, 639, 339))
        self.scrollAreaWidgetContents_5.setObjectName(
            "scrollAreaWidgetContents_5")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(
            self.scrollAreaWidgetContents_5)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.tabla_error = QtWidgets.QTableWidget(
            self.scrollAreaWidgetContents_5)
        self.tabla_error.setObjectName("tabla_error")
        self.tabla_error.setColumnCount(0)
        self.tabla_error.setRowCount(0)
        self.horizontalLayout_2.addWidget(self.tabla_error)
        self.scrollArea_5.setWidget(self.scrollAreaWidgetContents_5)
        self.tab_reporte.addTab(self.tab_6, "")
        self.tab_9 = QtWidgets.QWidget()
        self.tab_9.setObjectName("tab_9")
        self.textEdit = QtWidgets.QTextEdit(self.tab_9)
        self.textEdit.setGeometry(QtCore.QRect(10, 20, 631, 321))
        self.textEdit.setObjectName("textEdit")
        self.tab_reporte.addTab(self.tab_9, "")
        self.scrollArea.setWidget(self.scrollAreaWidgetContents)
        self.tabWidget.addTab(self.tab_3, "")
        self.tab_13 = QtWidgets.QWidget()
        self.tab_13.setObjectName("tab_13")
        self.tabWidget.addTab(self.tab_13, "")
        self.tab_7 = QtWidgets.QWidget()
        self.tab_7.setObjectName("tab_7")
        self.tabWidget.addTab(self.tab_7, "")
        self.btn_ejecutar_desc = QtWidgets.QPushButton(self.centralwidget)
        self.btn_ejecutar_desc.setGeometry(QtCore.QRect(960, 270, 81, 41))
        self.btn_ejecutar_desc.setObjectName("btn_ejecutar_desc")
        self.btn_ejecutar_minor_c = QtWidgets.QPushButton(self.centralwidget)
        self.btn_ejecutar_minor_c.setGeometry(QtCore.QRect(950, 170, 101, 41))
        self.btn_ejecutar_minor_c.setObjectName("btn_ejecutar_minor_c")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1074, 21))
        self.menubar.setObjectName("menubar")
        self.menuArchivo = QtWidgets.QMenu(self.menubar)
        self.menuArchivo.setObjectName("menuArchivo")
        self.menuEditar = QtWidgets.QMenu(self.menubar)
        self.menuEditar.setObjectName("menuEditar")
        self.menuAnalisis = QtWidgets.QMenu(self.menubar)
        self.menuAnalisis.setObjectName("menuAnalisis")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionGuardar = QtWidgets.QAction(MainWindow)
        self.actionGuardar.setObjectName("actionGuardar")
        self.actionGuardar_Como = QtWidgets.QAction(MainWindow)
        self.actionGuardar_Como.setObjectName("actionGuardar_Como")
        self.actionGuardar_Como_2 = QtWidgets.QAction(MainWindow)
        self.actionGuardar_Como_2.setObjectName("actionGuardar_Como_2")
        self.actionAscendente = QtWidgets.QAction(MainWindow)
        self.actionAscendente.setObjectName("actionAscendente")
        self.actionDescendente = QtWidgets.QAction(MainWindow)
        self.actionDescendente.setObjectName("actionDescendente")
        self.actionReiniciar_Debug = QtWidgets.QAction(MainWindow)
        self.actionReiniciar_Debug.setObjectName("actionReiniciar_Debug")
        self.actionSiguiente_Paso_Debug = QtWidgets.QAction(MainWindow)
        self.actionSiguiente_Paso_Debug.setObjectName(
            "actionSiguiente_Paso_Debug")
        self.actionCopiar = QtWidgets.QAction(MainWindow)
        self.actionCopiar.setObjectName("actionCopiar")
        self.actionPegar = QtWidgets.QAction(MainWindow)
        self.actionPegar.setObjectName("actionPegar")
        self.actionBuscar = QtWidgets.QAction(MainWindow)
        self.actionBuscar.setObjectName("actionBuscar")
        self.actionReemplazar = QtWidgets.QAction(MainWindow)
        self.actionReemplazar.setObjectName("actionReemplazar")
        self.menuArchivo.addAction(self.actionGuardar)
        self.menuArchivo.addAction(self.actionGuardar_Como)
        self.menuArchivo.addAction(self.actionGuardar_Como_2)
        self.menuEditar.addAction(self.actionCopiar)
        self.menuEditar.addAction(self.actionPegar)
        self.menuEditar.addAction(self.actionBuscar)
        self.menuEditar.addAction(self.actionReemplazar)
        self.menuAnalisis.addAction(self.actionAscendente)
        self.menuAnalisis.addAction(self.actionDescendente)
        self.menuAnalisis.addAction(self.actionReiniciar_Debug)
        self.menuAnalisis.addAction(self.actionSiguiente_Paso_Debug)
        self.menubar.addAction(self.menuArchivo.menuAction())
        self.menubar.addAction(self.menuEditar.menuAction())
        self.menubar.addAction(self.menuAnalisis.menuAction())

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        self.tabWidget_4.setCurrentIndex(0)
        self.tabWidget_3.setCurrentIndex(0)
        self.tabWidget_2.setCurrentIndex(0)
        self.tab_reporte.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
        self.__myFont = QFont()
        self.__myFont.setPointSize(12)
        #=========================================================EDITORES===================================
        self.txt_minor_c = QsciScintilla()
        self.txt_minor_c.setText("")
        self.txt_minor_c.setUtf8(True)
        self.txt_minor_c.setFont(self.__myFont)

        # AJUSTES DE TEXTO
        self.txt_minor_c.setWrapMode(QsciScintilla.WrapWord)
        self.txt_minor_c.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
        self.txt_minor_c.setWrapIndentMode(QsciScintilla.WrapIndentIndented)

        # FIN DE LINEA
        self.txt_minor_c.setEolMode(QsciScintilla.EolWindows)
        self.txt_minor_c.setEolVisibility(False)

        # SANGRIA
        self.txt_minor_c.setIndentationsUseTabs(False)
        self.txt_minor_c.setTabWidth(4)
        self.txt_minor_c.setIndentationGuides(True)
        self.txt_minor_c.setTabIndents(True)
        self.txt_minor_c.setAutoIndent(True)

        self.txt_minor_c.setCaretForegroundColor(QColor("#ff0000ff"))
        self.txt_minor_c.setCaretLineVisible(True)
        self.txt_minor_c.setCaretLineBackgroundColor(QColor("#1f0000ff"))
        self.txt_minor_c.setCaretWidth(2)

        # MARGENES
        self.txt_minor_c.setMarginType(0, QsciScintilla.NumberMargin)
        self.txt_minor_c.setMarginWidth(
            0, "0000")  # con este se puede quitar la linea
        self.txt_minor_c.setMarginsForegroundColor(QColor("#ff888888"))

        # SE COLOCAN LAS REGLAS DEL EDITOR
        self.__lexer = QsciLexerCPP(self.txt_minor_c)
        self.txt_minor_c.setLexer(self.__lexer)

        self.__lyt = QVBoxLayout()
        self.frame_txt_minor_c.setLayout(self.__lyt)
        self.__lyt.addWidget(self.txt_minor_c)
        #====================================ENTRADA===========================
        self.txt_entrada = QsciScintilla()
        self.txt_entrada.setText("")
        self.txt_entrada.setUtf8(True)
        self.txt_entrada.setFont(self.__myFont)

        # AJUSTES DE TEXTO
        self.txt_entrada.setWrapMode(QsciScintilla.WrapWord)
        self.txt_entrada.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
        self.txt_entrada.setWrapIndentMode(QsciScintilla.WrapIndentIndented)

        # FIN DE LINEA
        self.txt_entrada.setEolMode(QsciScintilla.EolWindows)
        self.txt_entrada.setEolVisibility(False)

        # SANGRIA
        self.txt_entrada.setIndentationsUseTabs(False)
        self.txt_entrada.setTabWidth(4)
        self.txt_entrada.setIndentationGuides(True)
        self.txt_entrada.setTabIndents(True)
        self.txt_entrada.setAutoIndent(True)

        self.txt_entrada.setCaretForegroundColor(QColor("#ff0000ff"))
        self.txt_entrada.setCaretLineVisible(True)
        self.txt_entrada.setCaretLineBackgroundColor(QColor("#1f0000ff"))
        self.txt_entrada.setCaretWidth(2)

        # MARGENES
        self.txt_entrada.setMarginType(0, QsciScintilla.NumberMargin)
        self.txt_entrada.setMarginWidth(
            0, "0000")  # con este se puede quitar la linea
        self.txt_entrada.setMarginsForegroundColor(QColor("#ff888888"))

        # SE COLOCAN LAS REGLAS DEL EDITOR
        self.__lexer = QsciLexerRuby(self.txt_entrada)
        self.txt_entrada.setLexer(self.__lexer)

        self.__lyt = QVBoxLayout()
        self.frame_txt_entrada.setLayout(self.__lyt)
        self.__lyt.addWidget(self.txt_entrada)
        #========================Entrada Sin Optimizar======================
        self.txt_entrada_sin_optimizar = QsciScintilla()
        self.txt_entrada_sin_optimizar.setText("")
        self.txt_entrada_sin_optimizar.setUtf8(True)
        self.txt_entrada_sin_optimizar.setFont(self.__myFont)

        # AJUSTES DE TEXTO
        self.txt_entrada_sin_optimizar.setWrapMode(QsciScintilla.WrapWord)
        self.txt_entrada_sin_optimizar.setWrapVisualFlags(
            QsciScintilla.WrapFlagByText)
        self.txt_entrada_sin_optimizar.setWrapIndentMode(
            QsciScintilla.WrapIndentIndented)

        # FIN DE LINEA
        self.txt_entrada_sin_optimizar.setEolMode(QsciScintilla.EolWindows)
        self.txt_entrada_sin_optimizar.setEolVisibility(False)

        # SANGRIA
        self.txt_entrada_sin_optimizar.setIndentationsUseTabs(False)
        self.txt_entrada_sin_optimizar.setTabWidth(4)
        self.txt_entrada_sin_optimizar.setIndentationGuides(True)
        self.txt_entrada_sin_optimizar.setTabIndents(True)
        self.txt_entrada_sin_optimizar.setAutoIndent(True)

        self.txt_entrada_sin_optimizar.setCaretForegroundColor(
            QColor("#ff0000ff"))
        self.txt_entrada_sin_optimizar.setCaretLineVisible(True)
        self.txt_entrada_sin_optimizar.setCaretLineBackgroundColor(
            QColor("#1f0000ff"))
        self.txt_entrada_sin_optimizar.setCaretWidth(2)

        # MARGENES
        self.txt_entrada_sin_optimizar.setMarginType(
            0, QsciScintilla.NumberMargin)
        self.txt_entrada_sin_optimizar.setMarginWidth(
            0, "0000")  # con este se puede quitar la linea
        self.txt_entrada_sin_optimizar.setMarginsForegroundColor(
            QColor("#ff888888"))

        # SE COLOCAN LAS REGLAS DEL EDITOR
        self.__lexer = QsciLexerRuby(self.txt_entrada_sin_optimizar)
        self.txt_entrada_sin_optimizar.setLexer(self.__lexer)

        self.__lyt = QVBoxLayout()
        self.frame_txt_entrada_sin_optimizar.setLayout(self.__lyt)
        self.__lyt.addWidget(self.txt_entrada_sin_optimizar)

        #======================================================================

        #Para Abrir,Guardar,Como
        self.btn_abrir.clicked.connect(self.abrir_archivo)
        self.actionGuardar.triggered.connect(self.abrir_archivo)
        self.btn_guardar_como.clicked.connect(self.guardar_archivo_como)
        self.actionGuardar_Como_2.triggered.connect(self.guardar_archivo_como)
        self.actionGuardar_Como.triggered.connect(self.guardar_archivo)
        self.btn_guardar.clicked.connect(self.guardar_archivo)
        #Ejecucion
        self.btn_ejecutar.clicked.connect(self.parser)
        self.actionAscendente.triggered.connect(self.parser)
        self.btn_ejecutar_desc.clicked.connect(self.parser_descendente)
        self.actionDescendente.triggered.connect(self.parser_descendente)
        self.btn_debug.clicked.connect(self.parser_paso_iniciar)
        self.actionReiniciar_Debug.triggered.connect(self.parser_paso_iniciar)
        self.btn_siguiente_paso.clicked.connect(self.parser_paso_ejecutar)
        self.actionSiguiente_Paso_Debug.triggered.connect(
            self.parser_paso_ejecutar)

        self.btn_ejecutar_minor_c.clicked.connect(self.ejecutar_main_c)

    def ejecutar_main_c(self):
        from AProyecto2.Main import analizar_minor_c, analizar_minor_c_optimizar_3D

        rst = analizar_minor_c_optimizar_3D(self.txt_minor_c.text())
        self.txt_entrada.setText(rst)

    def graficar_arbol(self):
        import pydot
        global Ts
        dot_string = Ts.generar_dot()
        graphs = pydot.graph_from_dot_data(dot_string)

        from PyQt5.QtWidgets import QApplication
        # app = QApplication(sys.argv)
        # win = QWidget()
        # l1 = QLabel()
        from PyQt5.QtGui import QPixmap
        qp = QPixmap()
        qp.loadFromData(graphs[0].create_png())
        self.lbl_graphviz.resize(qp.size())
        # m_imageLabel->resize(m_scaleFactor * m_imageLabel->size());
        self.lbl_graphviz.setPixmap(qp)

        # vbox = QVBoxLayout()
        # vbox.addWidget(l1)
        # win.setLayout(vbox)
        # win.setWindowTitle("QPixmap Demo")
        # win.show()
        # sys.exit(app.exec_())

    archivo_actual = None

    def guardar_archivo(self):
        if self.archivo_actual is None:
            self.guardar_archivo_como()
        else:
            file = open(self.archivo_actual, 'w')
            text = self.txt_entrada.text()
            file.write(text)
            self.color(text)

    def guardar_archivo_como(self):
        try:
            fname = QFileDialog.getSaveFileName()
            file = open(fname[0], 'w')
            text = self.txt_entrada.text()
            file.write(text)
            self.color(text)
        except:
            pass

    def abrir_archivo(self):
        try:
            fname = QFileDialog.getOpenFileName()
            f = open(fname[0], "r")
            input: str = f.read()
            self.color(input)
            self.archivo_actual = fname[0]
            self.txt_minor_c.setText(input)
        except:
            pass

    def color(self, input):
        return

    def parser_paso_iniciar(self):
        self.pasex = 1
        self.ejecutar_main_c()
        try:

            self.txt_consola.clear()
            dim = self.txt_entrada.text()
            input = dim
            global Ts
            Ts.guardar_consola(self.txt_consola)
            Ts.nueva_ejecucion(input)
            raiz_produccion: ListaInstruccion = analizar_ascendente(input)
            self.raiz_global = raiz_produccion
            Ts.guardar_tabla_etiqueta(self.tabla_etiqueta)
            Ts.guardar_tabla_error(self.tabla_error)
            if raiz_produccion is not None:
                Ts.cargar_etiquetas(raiz_produccion)
            else:
                Ts.mensaje_info("Error", "Error En El Codigo")
            #self.color()
            self.graficar_arbol()

            treeView = self.treeView
            treeView.setHeaderHidden(True)
            Ts.guardar_arbol(treeView)
            Ts.actualizar_arbol()

            self.textEdit.clear()
            self.textEdit.append("<div contenteditable>" + Ts.rp_cabecera() +
                                 "</div>")
        except:
            import sys
            Ts.mensaje_info("Error", "Error Durante El Analisis")
            print("Oops!", sys.exc_info()[0], "occurred.")

    raiz_global = None
    pasex = 1

    def parser_paso_ejecutar(self):

        try:

            if self.raiz_global is not None:
                #DEFAULT_INDICATOR_ID = 1
                #self.txt_entrada.indicatorDefine(QsciScintilla.FullBoxIndicator, self.pasex)
                #self.txt_entrada.fillIndicatorRange(self.pasex, 0, self.pasex + 1, 0, self.pasex)
                #self.pasex+=1

                #print(self.pasex)
                ex = Ts.paso_a_paso_ejecutar()
                if ex == "exit":
                    Ts.mensaje_info("Informacion",
                                    "Ejecucion Paso A Paso Completo")
                    self.raiz_global = None
                treeView = self.treeView
                treeView.setHeaderHidden(True)
                Ts.guardar_arbol(treeView)
                Ts.actualizar_arbol()
            else:
                Ts.mensaje_info("Ejecucion", "No hay nada que ejecutar")

        except:
            import sys
            Ts.mensaje_info("Error", "Error Durante El Analisis")
            print("Oops!", sys.exc_info()[0], "occurred.")

    def parser(self):
        try:
            self.txt_consola.clear()

            global Ts
            Ts.guardar_consola(self.txt_consola)

            dim = self.txt_entrada.text()
            input = dim

            Ts.nueva_ejecucion(input)
            raiz_produccion: ListaInstruccion = analizar_ascendente(input)
            Ts.guardar_tabla_etiqueta(self.tabla_etiqueta)
            Ts.guardar_tabla_error(self.tabla_error)
            if raiz_produccion is not None:
                Ts.cargar_etiquetas(raiz_produccion)
                Ts.ejecutar_main()
            else:
                Ts.mensaje_info("Error", "Error En El Codigo ")

            #self.color()
            self.graficar_arbol()

            treeView = self.treeView
            treeView.setHeaderHidden(True)
            Ts.guardar_arbol(treeView)
            Ts.actualizar_arbol()

            self.textEdit.clear()
            self.textEdit.append("<div contenteditable>" + Ts.rp_cabecera() +
                                 "</div>")
        except:
            import sys
            Ts.mensaje_info("Error", "Error Durante El Analisis")
            print("Oops!", sys.exc_info()[0], "occurred.")

    def parser_descendente(self):
        try:
            self.txt_consola.clear()
            global Ts
            Ts.guardar_consola(self.txt_consola)
            dim = self.txt_entrada.text()
            input = dim
            Ts.nueva_ejecucion(input)
            from Contenido.Analizadores.SintacticoDescendente import analizar_descendente
            raiz_produccion: ListaInstruccion = analizar_descendente(input)
            Ts.guardar_tabla_etiqueta(self.tabla_etiqueta)
            Ts.guardar_tabla_error(self.tabla_error)
            if raiz_produccion is not None:
                Ts.cargar_etiquetas(raiz_produccion)
                Ts.ejecutar_main()
            else:
                Ts.mensaje_info("Error", "Error En El Codigo")

            #self.color()
            self.graficar_arbol()

            treeView = self.treeView
            treeView.setHeaderHidden(True)
            Ts.guardar_arbol(treeView)
            Ts.actualizar_arbol()

            self.textEdit.clear()
            self.textEdit.append("<div contenteditable>" + Ts.rp_cabecera() +
                                 "</div>")
        except:
            import sys
            Ts.mensaje_info("Error", "Error Durante El Analisis")
            print("Oops!", sys.exc_info()[0], "occurred.")

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.btn_abrir.setText(_translate("MainWindow", "Abrir"))
        self.btn_guardar.setText(_translate("MainWindow", "Guardar"))
        self.btn_guardar_como.setText(
            _translate("MainWindow", "Guardar\n"
                       "Como"))
        self.btn_ejecutar.setText(
            _translate("MainWindow", "Ejecutar\n"
                       "Ascendente"))
        self.btn_debug.setText(_translate("MainWindow", "Debug"))
        self.btn_siguiente_paso.setText(
            _translate("MainWindow", "Siguiente\n"
                       "Paso"))
        self.tabWidget_3.setTabText(self.tabWidget_3.indexOf(self.tab_10),
                                    _translate("MainWindow", "Optimizada"))
        self.tabWidget_3.setTabText(self.tabWidget_3.indexOf(self.tab_11),
                                    _translate("MainWindow", "Sin Optimizar"))
        self.tabWidget_4.setTabText(
            self.tabWidget_4.indexOf(self.tab_8),
            _translate("MainWindow", "Salida De MinorC"))
        self.tabWidget_2.setTabText(
            self.tabWidget_2.indexOf(self.tab_12),
            _translate("MainWindow", "Entrada Minor C"))
        self.tabWidget_2.setTabText(
            self.tabWidget_2.indexOf(self.tab_5),
            _translate("MainWindow", "Tabla De Simbolos"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab),
                                  _translate("MainWindow", "Archivo Entrada"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2),
                                  _translate("MainWindow", "Visualizar"))
        self.tab_reporte.setTabText(self.tab_reporte.indexOf(self.tab_4),
                                    _translate("MainWindow", "Etiquetas"))
        self.tab_reporte.setTabText(self.tab_reporte.indexOf(self.tab_6),
                                    _translate("MainWindow", "Errores"))
        self.tab_reporte.setTabText(self.tab_reporte.indexOf(self.tab_9),
                                    _translate("MainWindow", "Gramatical"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3),
                                  _translate("MainWindow", "Reporte"))
        self.tabWidget.setTabText(
            self.tabWidget.indexOf(self.tab_13),
            _translate("MainWindow", "Visualizar Minor C"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_7),
                                  _translate("MainWindow", "Reporte Minor C"))
        self.btn_ejecutar_desc.setText(
            _translate("MainWindow", "Ejecutar\n"
                       "Descendente"))
        self.btn_ejecutar_minor_c.setText(
            _translate("MainWindow", "Ejecutar Minor C"))
        self.menuArchivo.setTitle(_translate("MainWindow", "Archivo"))
        self.menuEditar.setTitle(_translate("MainWindow", "Editar"))
        self.menuAnalisis.setTitle(_translate("MainWindow", "Analisis"))
        self.actionGuardar.setText(_translate("MainWindow", "Abrir"))
        self.actionGuardar_Como.setText(_translate("MainWindow", "Guardar"))
        self.actionGuardar_Como_2.setText(
            _translate("MainWindow", "Guardar Como"))
        self.actionAscendente.setText(_translate("MainWindow", "Ascendente"))
        self.actionDescendente.setText(_translate("MainWindow", "Descendente"))
        self.actionReiniciar_Debug.setText(
            _translate("MainWindow", "Reiniciar Debug"))
        self.actionSiguiente_Paso_Debug.setText(
            _translate("MainWindow", "Siguiente Paso Debug"))
        self.actionCopiar.setText(_translate("MainWindow", "Copiar"))
        self.actionPegar.setText(_translate("MainWindow", "Pegar"))
        self.actionBuscar.setText(_translate("MainWindow", "Buscar"))
        self.actionReemplazar.setText(_translate("MainWindow", "Reemplazar"))
コード例 #5
0
class CustomMainWindow(QMainWindow):
    def __init__(self):
        super(CustomMainWindow, self).__init__()

        # -------------------------------- #
        #           Window setup           #
        # -------------------------------- #

        # 1. Define the geometry of the main window
        # ------------------------------------------
        self.setGeometry(300, 300, 800, 400)
        self.setWindowTitle("QScintilla Test")

        # 2. Create frame and layout
        # ---------------------------
        self.__frm = QFrame(self)
        self.__frm.setStyleSheet("QWidget { background-color: #ffeaeaea }")
        self.__lyt = QVBoxLayout()
        self.__frm.setLayout(self.__lyt)
        self.setCentralWidget(self.__frm)
        self.__myFont = QFont()
        self.__myFont.setPointSize(14)

        # 3. Place a button
        # ------------------
        self.__btn = QPushButton("Qsci")
        self.__btn.setFixedWidth(50)
        self.__btn.setFixedHeight(50)
        self.__btn.clicked.connect(self.__btn_action)
        self.__btn.setFont(self.__myFont)
        self.__lyt.addWidget(self.__btn)

        # -------------------------------- #
        #     QScintilla editor setup      #
        # -------------------------------- #

        # ! Make instance of QSciScintilla class!
        # ----------------------------------------
        self.__editor = QsciScintilla()
        self.__editor.setText("This\n")  # Line 1
        self.__editor.append("is\n")  # Line 2
        self.__editor.append("a\n")  # Line 3
        self.__editor.append("QScintilla\n")  # Line 4
        self.__editor.append("test\n")  # Line 5
        self.__editor.append("program\n")  # Line 6
        self.__editor.append("to\n")  # Line 7
        self.__editor.append("illustrate\n")  # Line 8
        self.__editor.append("some\n")  # Line 9
        self.__editor.append("basic\n")  # Line 10
        self.__editor.append("functions.")  # Line 11
        self.__editor.setLexer(None)
        self.__editor.setUtf8(True)  # Set encoding to UTF-8
        self.__editor.setFont(self.__myFont)

        # 1. Text wrapping
        # -----------------
        self.__editor.setWrapMode(QsciScintilla.WrapWord)
        self.__editor.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
        self.__editor.setWrapIndentMode(QsciScintilla.WrapIndentIndented)

        # 2. End-of-line mode
        # --------------------
        self.__editor.setEolMode(QsciScintilla.EolWindows)
        self.__editor.setEolVisibility(False)

        # 3. Indentation
        # ---------------
        self.__editor.setIndentationsUseTabs(False)
        self.__editor.setTabWidth(4)
        self.__editor.setIndentationGuides(True)
        self.__editor.setTabIndents(True)
        self.__editor.setAutoIndent(True)

        # 4. Caret
        # ---------
        self.__editor.setCaretForegroundColor(QColor("#ff0000ff"))
        self.__editor.setCaretLineVisible(True)
        self.__editor.setCaretLineBackgroundColor(QColor("#1f0000ff"))
        self.__editor.setCaretWidth(2)

        # 5. Margins
        # -----------
        # Margin 0 = Line nr margin
        self.__editor.setMarginType(0, QsciScintilla.NumberMargin)
        self.__editor.setMarginWidth(0, "0000")
        self.__editor.setMarginsForegroundColor(QColor("#ff888888"))

        # Margin 1 = Symbol margin
        self.__editor.setMarginType(1, QsciScintilla.SymbolMargin)
        self.__editor.setMarginWidth(1, "00000")
        sym_0 = QImage("icons/sym_0.png").scaled(QSize(16, 16))
        sym_1 = QImage("icons/sym_1.png").scaled(QSize(16, 16))
        sym_2 = QImage("icons/sym_2.png").scaled(QSize(16, 16))
        sym_3 = QImage("icons/sym_3.png").scaled(QSize(16, 16))

        self.__editor.markerDefine(sym_0, 0)
        self.__editor.markerDefine(sym_1, 1)
        self.__editor.markerDefine(sym_2, 2)
        self.__editor.markerDefine(sym_3, 3)

        self.__editor.setMarginMarkerMask(1, 0b1111)

        # 6. Margin mouse clicks
        # -----------------------
        self.__editor.setMarginSensitivity(1, True)
        self.__editor.marginClicked.connect(self.__margin_left_clicked)
        self.__editor.marginRightClicked.connect(self.__margin_right_clicked)

        # ! Add editor to layout !
        # -------------------------
        self.__lyt.addWidget(self.__editor)
        self.show()

    ''''''

    def __margin_left_clicked(self, margin_nr, line_nr, state):
        print("Margin clicked (left mouse btn)!")
        print(" -> margin_nr: " + str(margin_nr))
        print(" -> line_nr:   " + str(line_nr))
        print("")

        if state == Qt.ControlModifier:
            # Show green dot.
            self.__editor.markerAdd(line_nr, 0)

        elif state == Qt.ShiftModifier:
            # Show green arrow.
            self.__editor.markerAdd(line_nr, 1)

        elif state == Qt.AltModifier:
            # Show red dot.
            self.__editor.markerAdd(line_nr, 2)

        else:
            # Show red arrow.
            self.__editor.markerAdd(line_nr, 3)

    ''''''

    def __margin_right_clicked(self, margin_nr, line_nr, state):
        print("Margin clicked (right mouse btn)!")
        print(" -> margin_nr: " + str(margin_nr))
        print(" -> line_nr:   " + str(line_nr))
        print("")

    ''''''

    def __btn_action(self):
        print("Hello World!")

    ''''''
コード例 #6
0
class CustomMainWindow(QMainWindow):
    def __init__(self):
        super(CustomMainWindow, self).__init__()

        # -------------------------------- #
        #           Window setup           #
        # -------------------------------- #

        # 1. Define the geometry of the main window
        # ------------------------------------------
        self.setGeometry(300, 300, 800, 400)
        self.setWindowTitle("QScintilla Test")

        # 2. Create frame and layout
        # ---------------------------
        self.__frm = QFrame(self)
        self.__frm.setStyleSheet("QWidget { background-color: #ffeaeaea }")
        self.__lyt = QVBoxLayout()
        self.__frm.setLayout(self.__lyt)
        self.setCentralWidget(self.__frm)
        self.__myFont = QFont()
        self.__myFont.setPointSize(14)

        # 3. Place a button
        # ------------------
        self.__btn = QPushButton("Qsci")
        self.__btn.setFixedWidth(50)
        self.__btn.setFixedHeight(50)
        self.__btn.clicked.connect(self.__btn_action)
        self.__btn.setFont(self.__myFont)
        self.__lyt.addWidget(self.__btn)

        # -------------------------------- #
        #     QScintilla editor setup      #
        # -------------------------------- #

        # ! Make instance of QSciScintilla class!
        # ----------------------------------------
        self.__editor = QsciScintilla()
        self.__editor.setText("This\n")         # Line 1
        self.__editor.append("is\n")            # Line 2
        self.__editor.append("a\n")             # Line 3
        self.__editor.append("QScintilla\n")    # Line 4
        self.__editor.append("test\n")          # Line 5
        self.__editor.append("program\n")       # Line 6
        self.__editor.append("to\n")            # Line 7
        self.__editor.append("illustrate\n")    # Line 8
        self.__editor.append("some\n")          # Line 9
        self.__editor.append("basic\n")         # Line 10
        self.__editor.append("functions.")      # Line 11
        self.__editor.setLexer(None)
        self.__editor.setUtf8(True)             # Set encoding to UTF-8
        self.__editor.setFont(self.__myFont)

        # 1. Text wrapping
        # -----------------
        self.__editor.setWrapMode(QsciScintilla.WrapWord)
        self.__editor.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
        self.__editor.setWrapIndentMode(QsciScintilla.WrapIndentIndented)

        # 2. End-of-line mode
        # --------------------
        self.__editor.setEolMode(QsciScintilla.EolWindows)
        self.__editor.setEolVisibility(False)

        # 3. Indentation
        # ---------------
        self.__editor.setIndentationsUseTabs(False)
        self.__editor.setTabWidth(4)
        self.__editor.setIndentationGuides(True)
        self.__editor.setTabIndents(True)
        self.__editor.setAutoIndent(True)

        # 4. Caret
        # ---------
        self.__editor.setCaretForegroundColor(QColor("#ff0000ff"))
        self.__editor.setCaretLineVisible(True)
        self.__editor.setCaretLineBackgroundColor(QColor("#1f0000ff"))
        self.__editor.setCaretWidth(2)

        # 5. Margins
        # -----------
        # Margin 0 = Line nr margin
        self.__editor.setMarginType(0, QsciScintilla.NumberMargin)
        self.__editor.setMarginWidth(0, "0000")
        self.__editor.setMarginsForegroundColor(QColor("#ff888888"))

        # Margin 1 = Symbol margin
        self.__editor.setMarginType(1, QsciScintilla.SymbolMargin)
        self.__editor.setMarginWidth(1, "00000")
        sym_0 = QImage("icons/sym_0.png").scaled(QSize(16, 16))
        sym_1 = QImage("icons/sym_1.png").scaled(QSize(16, 16))
        sym_2 = QImage("icons/sym_2.png").scaled(QSize(16, 16))
        sym_3 = QImage("icons/sym_3.png").scaled(QSize(16, 16))

        self.__editor.markerDefine(sym_0, 0)
        self.__editor.markerDefine(sym_1, 1)
        self.__editor.markerDefine(sym_2, 2)
        self.__editor.markerDefine(sym_3, 3)

        self.__editor.setMarginMarkerMask(1, 0b1111)

        # Display a few symbols, and keep their handles stored
        handle_01 = self.__editor.markerAdd(0, 0)   # Green dot on line 0+1
        handle_02 = self.__editor.markerAdd(4, 0)   # Green dot on line 4+1
        handle_03 = self.__editor.markerAdd(5, 0)   # Green dot on line 5+1
        handle_04 = self.__editor.markerAdd(8, 3)   # Red arrow on line 8+1
        handle_05 = self.__editor.markerAdd(9, 2)   # Red dot on line 9+1


        # ! Add editor to layout !
        # -------------------------
        self.__lyt.addWidget(self.__editor)
        self.show()

    ''''''

    def __btn_action(self):
        print("Hello World!")

    ''''''
コード例 #7
0
class CypherEditGridWidget(QWidget, Ui_cypherEditGridWidget):
    """
    Class documentation goes here.
    """
    def __init__(self, parent=None, fileName=None, fileText=None, mode=None):
        """
        Constructor
        
        @param parent reference to the parent widget
        @type QWidget
        """
        super(CypherEditGridWidget, self).__init__(parent)
        self.setupUi(self)
        self.parent = parent
        self.settings = QSettings()
        self.initUI()
        self.initScintilla()
        self.helper = Helper()
        self.mode = mode
        self.tabType = "CYPHER"
        self.tabName = fileName
        self.tabIndex = None  # this is the index into the tabWidget of the tab this widget is on
        self.fileName = fileName
        self.fileText = fileText
        self.resultSet = None

        # create a neocon object for this file tab
        self.neoDriver = NeoDriver(name=self.parent.pageItem.neoConName,
                                   promptPW=self.parent.pageItem.promptPW)

        # add the data grid widget.
        self.dataGridGeneric = DataGridGeneric()
        self.dataGrid = DataGridWidget(self,
                                       neoCon=self.neoDriver,
                                       genCypher=self.dataGridGeneric)
        self.nodeGridLayout = QVBoxLayout(self.frmDataGrid)
        self.nodeGridLayout.setObjectName("nodeGridLayout")
        self.nodeGridLayout.setContentsMargins(1, 1, 1, 1)
        self.nodeGridLayout.setSpacing(1)
        self.nodeGridLayout.addWidget(self.dataGrid)

        if self.mode == MODENEW:
            if not self.fileText is None:
                self.loadText()

        if self.mode == MODEEDIT:
            self.loadFile()

        # position the splitter
        self.show(
        )  # you have to do this to force all the widgets sizes to update
        half = int((self.frmEditnGrid.height() / 2))
        self.splitter.setSizes([half, half])

    def logMsg(self, msg):

        if logging:
            logging.info(msg)

    def initUI(self, ):
        #initialize state of commit buttons and dropdown
        self.btnCommit.setEnabled(False)
        self.btnRollBack.setEnabled(False)
        self.cmbAutoCommit.setCurrentIndex(0)

    def initScintilla(self):
        # add and initialize the control to self.frmEditor
        self.editor = QsciScintilla()
        self.editor.setLexer(None)
        self.editor.setUtf8(True)  # Set encoding to UTF-8
        self.editor.setWrapMode(QsciScintilla.WrapNone)
        self.editor.setEolVisibility(False)
        self.editor.setIndentationsUseTabs(False)
        self.editor.setTabWidth(4)
        self.editor.setIndentationGuides(True)
        self.editor.setAutoIndent(True)
        self.editor.setMarginType(0, QsciScintilla.NumberMargin)
        self.editor.setMarginWidth(0, "00000")
        self.editor.setMarginsForegroundColor(QColor("#ffffffff"))
        self.editor.setMarginsBackgroundColor(QColor("#00000000"))
        self.verticalLayout_2.addWidget(self.editor)
        # setup the lexer
        self.lexer = CypherLexer(self.editor)
        self.editor.setLexer(self.lexer)
        self.setScintillaFontSize()
        self.editor.SendScintilla(self.editor.SCI_GETCURRENTPOS, 0)
        self.editor.setCaretForegroundColor(QColor("#ff0000ff"))
        self.editor.setCaretLineVisible(True)
        self.editor.setCaretLineBackgroundColor(QColor("#1f0000ff"))
        self.editor.setCaretWidth(2)
        self.editor.setBraceMatching(QsciScintilla.SloppyBraceMatch)

    def setScintillaFontSize(self, ):
        # set font size to value saved in settings
        try:
            fontSize = int(self.settings.value("Lexer/FontSize", "10"))
        except:
            fontSize = 10
        finally:
            for style in range(5):
                self.editor.SendScintilla(QsciScintilla.SCI_STYLESETSIZE,
                                          style, fontSize)
            self.editor.SendScintilla(QsciScintilla.SCI_STYLESETSIZE, 34,
                                      fontSize)
            self.editor.SendScintilla(QsciScintilla.SCI_STYLESETSIZE, 35,
                                      fontSize)

#####################################################################################
# methods related to the cypher file
#####################################################################################

    def loadText(self, ):
        QApplication.setOverrideCursor(Qt.WaitCursor)
        self.editor.append(self.fileText)
        self.editor.setModified(True)
        QApplication.restoreOverrideCursor()

    def loadFile(self, ):
        file = QFile(self.fileName)
        if not file.open(QFile.ReadOnly | QFile.Text):
            QMessageBox.warning(
                self, "NodeMaker", "Cannot read file %s:\n%s." %
                (self.fileName, file.errorString()))
            return False

        instr = QTextStream(file)
        QApplication.setOverrideCursor(Qt.WaitCursor)
        self.editor.append(instr.readAll())
        self.editor.setModified(False)
        QApplication.restoreOverrideCursor()

    def save(self, ):
        if self.mode == MODENEW:
            self.saveAs()
        else:
            self.saveIt()

    def saveAs(self, ):
        # first test to see if the file has changed

        # get filename to save as
        #
        dlg = QFileDialog()
        dlg.setAcceptMode(QFileDialog.AcceptSave)
        dlg.setDefaultSuffix("cyp")
        dlg.setNameFilters([
            "Cypher Query (*.cyp *.cypher)", "Cypher Query (*.cyp)",
            "Cypher Query (*.cypher)", "all files (*.*)"
        ])
        dlg.setDirectory(self.parent.settings.value("Default/ProjPath"))
        if dlg.exec_():
            fileNames = dlg.selectedFiles()
            if fileNames:
                self.fileName = fileNames[0]
                # save the file
                self.saveIt()

    def saveIt(self, ):
        file = QFile(self.fileName)
        if not file.open(QFile.WriteOnly | QFile.Text):
            QMessageBox.warning(
                self, "NodeEra", "Cannot write file %s:\n%s." %
                (self.fileName, file.errorString()))
            return

        outstr = QTextStream(file)
        QApplication.setOverrideCursor(Qt.WaitCursor)
        outstr << self.editor.text()
        head, tail = ntpath.split(QFileInfo(self.fileName).fileName())
        self.parent.tabCypher.setTabText(self.parent.tabCypher.currentIndex(),
                                         tail)
        self.mode = MODEEDIT
        QApplication.restoreOverrideCursor()

    def close(self, ):
        #        print("editngrid close {}".format(self.fileName))
        # see if there is an open transaction and cancel the close
        self.checkOpenTxn()
        # see if text has changed and save the file if the user wants to
        if self.editor.isModified():
            # see if the user wants to save it
            if self.fileName is None:
                # these are unsaved cypher files so they have no filename yet
                displayName = self.parent.tabCypher.tabText(self.tabIndex)
            else:
                displayName = self.fileName
            if self.helper.saveChangedObject("Cypher File", displayName):
                self.save()
        return True

##############################################################
# Button methods
##############################################################

    @pyqtSlot()
    def on_btnRun_clicked(self):
        """
        Run the query at the cursor.
        """
        self.runFileCursor()

    def runFileCursor(self):

        self.logMsg("User requests run Cypher in Cursor")
        # parse the text editor and get the index to the cypher command the cursor is pointing at
        currentCypherIndex = self.getSelectedCypher()
        # check if cursor in a query
        if currentCypherIndex is None:
            self.helper.displayErrMsg(
                "Run Query",
                "You must position cursor within the Cypher query.")
            QApplication.restoreOverrideCursor()
            return

        # get the cypher statement to be executed
        startOffset = self.cypherList[currentCypherIndex][0]
        self.dataGrid.cypher = self.cypherList[currentCypherIndex][1]

        # prompt the user for parameter values if any
        userCanceled = False
        if len(self.cypherParms[currentCypherIndex][1]) > 0:
            #            print("Parms:{}".format(self.cypherParms[currentCypherIndex][1]))
            # display dialog to gather parms
            d = CypherParmEntryDlg(
                parent=self, parms=self.cypherParms[currentCypherIndex][1])
            if d.exec_():
                self.dataGrid.parmData = d.parmDict
            else:
                userCanceled = True
                self.dataGrid.parmData = None
#            print("Parm Dictionary:{}".format(self.dataGrid.parmData))
        else:
            self.dataGrid.parmData = None

        # see if the user canceled the query rather than enter parameters
        if userCanceled:
            self.helper.displayErrMsg("Run Query", "User Canceled Query.")
            QApplication.restoreOverrideCursor()
            return

        # make sure the cypher is not just spaces, or nothing but a semicolon
        if (self.dataGrid.cypher.isspace() or len(self.dataGrid.cypher) == 0
                or self.dataGrid.cypher.strip() == ";"):
            self.helper.displayErrMsg(
                "Run Query",
                "You must position cursor within the Cypher query.")
        else:
            QApplication.setOverrideCursor(Qt.WaitCursor)
            self.dataGrid.refreshGrid()
            QApplication.restoreOverrideCursor()
        # see if there was a syntax error and position cursor
        try:
            offset = self.dataGrid.neoCon.cypherLogDict["offset"]
            if offset > -1:
                self.editor.SendScintilla(QsciScintilla.SCI_GOTOPOS,
                                          offset + startOffset)
        except:
            pass
        finally:
            ###  hack needed on mac os to force scintilla to show cursor and highlighted line
            self.helper.displayErrMsg("Run Query With Cursor",
                                      "Query Complete")

    def getSelectedCypher(self):
        '''
        Build a list of cypher commands from the text in the editor
        '''
        # get position of cursor which is a zero based offset, it seems to return zero if editor hasn't been clicked on yet
        try:
            position = self.editor.SendScintilla(
                QsciScintilla.SCI_GETCURRENTPOS, 0)
        except:
            position = 0
        # initialize cypherList
        self.cypherList = []
        self.cypherParms = []
        parmList = []
        currentCypherIndex = None
        # get the full text from the editor
        text = self.editor.text()
        # make sure there is something in the text
        if len(text) < 1:
            return currentCypherIndex

        #	Walk through all the characters in text, and store start offset and end offset of each command
        startOffset = 0
        endOffset = 0
        foundCypher = False  # tracks if we have found at least one character that is potentially a non-comment cypher command
        inComment = False  # tracks if we're looking at comment characters
        inParm = False  # tracks if we're looking at parameter characters
        inCypher = False  # tracks if we've found a non comment character while scanning
        newParm = ""
        for chrCtr in range(0, len(text)):
            #            print("before: chrCtr:{} char: {} ord:{} inComment:{} inParm:{} inCypher:{}".format(chrCtr, text[chrCtr], ord(text[chrCtr]), inComment, inParm, inCypher))

            # see if we're in a comment ( this doesn't work for multiline comments)
            if chrCtr + 1 < len(text) and text[chrCtr] == '/':
                inParm = False
                if text[chrCtr + 1] == "/":
                    inComment = True
                    inCypher = False
            # see if end of line
            elif ord(text[chrCtr]) in [13, 10]:
                inParm = False
                if chrCtr + 1 < len(text):
                    if not text[chrCtr + 1] in [13, 10]:
                        # end of line ends the comment
                        inComment = False

            elif text[chrCtr] == "$":
                if not inComment:
                    foundCypher = True
                    inParm = True
            elif text[chrCtr] == " ":
                if not inComment:
                    foundCypher = True
                inParm = False
            elif (text[chrCtr] == ";" and inComment == False):
                foundCypher = True
                inParm = False
                endOffset = chrCtr
                # save each command in the list
                self.cypherList.append(
                    [startOffset, text[startOffset:endOffset + 1]])
                self.cypherParms.append([startOffset, parmList])
                parmList = []
                # HAPPY PATH - see if this is the command where the cursor is located
                if (position >= startOffset and position <= endOffset):
                    currentCypherIndex = len(self.cypherList) - 1
                # set the next starting offset
                startOffset = chrCtr + 1
                endOffset = startOffset
            elif inComment == False:
                foundCypher = True
                inCypher = True

            if inParm:
                newParm = newParm + text[chrCtr]
            else:
                if len(newParm) > 0:
                    #                    print("Parameter: {}".format(newParm))
                    parmList.append(newParm)
                    newParm = ""

#            print("after: chrCtr:{} char: {} ord:{} inComment:{} inParm:{} inCypher:{}".format(chrCtr, text[chrCtr], ord(text[chrCtr]), inComment, inParm, inCypher))

# at this point all characters have been processed, must deal with edge cases, no final semicolon etc
        if len(
                self.cypherList
        ) == 0:  # we never found a semi colon so the entire file is one cypher statement
            # return the entire text file
            self.cypherList.append([0, text])
            self.cypherParms.append([0, parmList])
            parmList = []

            currentCypherIndex = 0
        else:  # we found some characters after the last semi colon.
            lastCypher = ""
            try:
                lastCypher = text[startOffset:len(text)]
                if lastCypher.isspace(
                ) == True:  # if there is only whitespace after the last semicolon then return the last found cypher
                    if currentCypherIndex is None:
                        currentCypherIndex = len(self.cypherList) - 1
                elif len(
                        lastCypher
                ) < 1:  # there are no characters after the last semicolon, but cursor is positioned past it then return the last found cypher
                    if currentCypherIndex is None:
                        currentCypherIndex = len(self.cypherList) - 1
                elif inCypher == False and foundCypher == False:  # none of the characters are outside a comment so return last found cypher
                    if currentCypherIndex is None:
                        currentCypherIndex = len(self.cypherList) - 1
                else:
                    self.cypherList.append(
                        [startOffset, lastCypher]
                    )  # since some characters are present, add them as the last cypher command
                    self.cypherParms.append([startOffset, parmList])
                    parmList = []

                    if currentCypherIndex is None:
                        currentCypherIndex = len(self.cypherList) - 1
            except:
                if currentCypherIndex is None:
                    currentCypherIndex = len(
                        self.cypherList
                    ) - 1  # return the last cypher command found if any error

#        print("cypher list: {}".format(self.cypherList))
        return currentCypherIndex

    @pyqtSlot()
    def on_btnRunScript_clicked(self):
        """
        this button will run all the cypher commands in the file one at a time.
        """

        self.runFileAsScript()

    def runFileAsScript(self, ):
        '''
        run each cypher command in the file one at a time.
        '''
        QApplication.setOverrideCursor(Qt.WaitCursor)
        self.logMsg("User requests run Cypher file as a script")
        # parse the text editor into cypher commands, we don't care which one the cursor is in
        self.getSelectedCypher()
        if len(self.cypherList) < 1:
            self.helper.displayErrMsg(
                "Run File As Script", "The file has no cypher commands in it.")
        for cypherCmd in self.cypherList:
            # this is the starting offset of the cypher command in the entire file
            cypherOffset = cypherCmd[0]
            self.dataGrid.cypher = cypherCmd[1]
            # set editor selection to the cypher command
            self.editor.SendScintilla(QsciScintilla.SCI_SETSEL, cypherOffset,
                                      cypherOffset + len(self.dataGrid.cypher))
            # skip any cypher is not just spaces, or nothing but a semicolon
            if (self.dataGrid.cypher.isspace()
                    or len(self.dataGrid.cypher) == 0
                    or self.dataGrid.cypher.strip() == ";"):
                #self.helper.displayErrMsg("Run Query",  "You must position cursor within the Cypher query.")
                pass
            else:
                self.dataGrid.refreshGrid()
                QApplication.processEvents()
            # see if there was a syntax error and position cursor
            try:
                offset = self.dataGrid.neoCon.cypherLogDict["offset"]
                if offset > -1:
                    self.editor.SendScintilla(QsciScintilla.SCI_GOTOPOS,
                                              offset + cypherOffset)
            except:
                pass
            # set editor selection to the end of the file
            self.editor.SendScintilla(QsciScintilla.SCI_SETSEL,
                                      len(self.editor.text()),
                                      len(self.editor.text()))

        QApplication.restoreOverrideCursor()

    @pyqtSlot()
    def on_btnCommit_clicked(self):
        """
        User clicks on the Commit button.  Commit the TXN.
        """
        self.doCommit()

    def doCommit(self):
        self.logMsg("User request Commit the transaction")
        if not self.neoDriver is None:
            rc, msg = self.neoDriver.commitTxn()
            self.logMsg("Commit Complete - {}".format(msg))

    @pyqtSlot()
    def on_btnRollBack_clicked(self):
        """
        User clicks on the Rollback button.  Rollback the TXN.
        """
        self.doRollBack()

    def doRollBack(self):
        self.logMsg("User request Rollback the transaction")
        if not self.neoDriver is None:
            rc, msg = self.neoDriver.rollbackTxn()
            self.logMsg("Rollback Complete - {}".format(msg))

    def zoomIn(self, ):
        """
        increase Font Size
        """
        #        self.editor.SendScintilla(QsciScintilla.SCI_ZOOMIN)
        #        currentFontSize = self.editor.SendScintilla(QsciScintilla.SCI_STYLEGETSIZE, 0)
        #        self.settings.setValue("Lexer/FontSize", currentFontSize)
        # get style 0 font size - all styles use same size
        currentFontSize = self.editor.SendScintilla(
            QsciScintilla.SCI_STYLEGETSIZE, 0)
        currentFontSize = currentFontSize + 2
        if currentFontSize < 24:
            self.settings.setValue("Lexer/FontSize", currentFontSize)
            for style in range(255):
                self.editor.SendScintilla(QsciScintilla.SCI_STYLESETSIZE,
                                          style, currentFontSize)
#            self.editor.SendScintilla(QsciScintilla.SCI_STYLESETSIZE, 34, currentFontSize)
#            self.editor.SendScintilla(QsciScintilla.SCI_STYLESETSIZE, 35, currentFontSize)

    def zoomOut(self, ):
        """
        decrease font size
        """
        #        self.editor.SendScintilla(QsciScintilla.SCI_ZOOMOUT)
        #        currentFontSize = self.editor.SendScintilla(QsciScintilla.SCI_STYLEGETSIZE, 0)
        #        self.settings.setValue("Lexer/FontSize", currentFontSize)

        # get style 0 font size - all styles use same size
        currentFontSize = self.editor.SendScintilla(
            QsciScintilla.SCI_STYLEGETSIZE, 0)
        currentFontSize = currentFontSize - 2
        if currentFontSize > 4:
            self.settings.setValue("Lexer/FontSize", currentFontSize)
            for style in range(255):  # was 5
                self.editor.SendScintilla(QsciScintilla.SCI_STYLESETSIZE,
                                          style, currentFontSize)
#            self.editor.SendScintilla(QsciScintilla.SCI_STYLESETSIZE, 34, currentFontSize)
#            self.editor.SendScintilla(QsciScintilla.SCI_STYLESETSIZE, 35, currentFontSize)

    def checkOpenTxn(self):
        '''
        check if current txn is still open.  
        if autocommit is false then ask the user to commit or rollback
        if autocommit is true then do the commit
        '''
        if not (self.neoDriver is None):
            if not (self.neoDriver.tx is None):
                if self.neoDriver.tx.closed() is False:
                    if self.neoDriver.autoCommit is True:
                        self.doCommit()
                    else:
                        # prompt user to commit or rollback the current transaction
                        msgBox = QMessageBox()
                        msgBox.setIcon(QMessageBox.Warning)
                        msgBox.setText(
                            "You have an uncommitted transaction. Do you want to commit? (click Yes to commit, No to rollback"
                        )
                        msgBox.setWindowTitle("Commit or Rollback")
                        msgBox.setStandardButtons(QMessageBox.Yes
                                                  | QMessageBox.No)
                        result = msgBox.exec_()
                        if result == QMessageBox.Yes:
                            self.doCommit()
                        else:
                            self.doRollBack()

    @pyqtSlot(int)
    def on_cmbAutoCommit_currentIndexChanged(self, index):
        """
        User has changed the auto commit dropdown.
        
        @param index DESCRIPTION
        @type int
        """
        self.logMsg("User request transaction mode changed to {}".format(
            self.cmbAutoCommit.currentText()))
        if self.cmbAutoCommit.currentText() == "Auto Commit On":
            self.checkOpenTxn()
            if not (self.neoDriver is None):
                self.neoDriver.setAutoCommit(True)
            self.btnCommit.setEnabled(False)
            self.btnRollBack.setEnabled(False)
        if self.cmbAutoCommit.currentText() == "Auto Commit Off":
            self.checkOpenTxn()
            if not (self.neoDriver is None):
                self.neoDriver.setAutoCommit(False)
            self.btnCommit.setEnabled(True)
            self.btnRollBack.setEnabled(True)