Пример #1
0
    def agregar_tab(self):
        text, okPressed = QInputDialog.getText(self.centralwidget,
                                               "Nuevo archivo", "Nombre:",
                                               QLineEdit.Normal, "")
        if okPressed and text != '':

            tab = QtWidgets.QWidget()
            area = QsciScintilla(tab)
            area.setGeometry(QtCore.QRect(10, 10, 631, 371))
            area.setObjectName("plainTextEdit")
            area.setFont(self.__myFont)
            area.setMarginType(0, QsciScintilla.NumberMargin)
            area.setMarginWidth(0, "00000")
            area.setMarginsForegroundColor(QtGui.QColor("#0C4B72"))
            area.markerDefine(QsciScintilla.RightArrow, 0)
            area.setMarginSensitivity(0, True)
            area.setWrapMode(QsciScintilla.WrapWord)
            area.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
            area.setWrapIndentMode(QsciScintilla.WrapIndentIndented)
            area.setEolMode(QsciScintilla.EolWindows)
            area.setEolVisibility(False)
            area.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
            area.marginClicked.connect(self.on_margin_clicked)
            __lexer = QsciLexerCPP(area)
            area.setLexer(__lexer)
            self.editor.addTab(tab, "")
            area.setObjectName("area")
            self.editor.addTab(tab, text + ".mc")
Пример #2
0
    def __init__(self, code):
        super(QDialog, self).__init__()

        self.codeEdit = QsciScintilla()
        self.codeEdit.setText(code)
        fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.codeEdit.setFont(fixedWidthFont)
        fontmetrics = QFontMetrics(fixedWidthFont)
        self.codeEdit.setMarginWidth(0, fontmetrics.width("000"))
        self.codeEdit.setMarginLineNumbers(0, True)
        self.codeEdit.setMarginsBackgroundColor(QColor("#cccccc"))

        self.codeEdit.setBraceMatching(QsciScintilla.SloppyBraceMatch)
        self.codeEdit.setCaretLineVisible(True)
        self.codeEdit.setCaretLineBackgroundColor(QColor("#ffe4e4"))
        lexer = QsciLexerPython()
        lexer.setDefaultFont(fixedWidthFont)
        self.codeEdit.setLexer(lexer)
        self.codeEdit.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
        self.codeEdit.setUtf8(True)

        self.codeEdit.setTabWidth(4)
        self.codeEdit.setIndentationsUseTabs(True)
        self.codeEdit.setIndentationGuides(True)
        self.codeEdit.setTabIndents(True)
        self.codeEdit.setAutoIndent(True)

        verticalLayout = QVBoxLayout()
        verticalLayout.addWidget(self.codeEdit)
        self.setLayout(verticalLayout)

        self.codeEdit.textChanged.connect(self.changeCode)
Пример #3
0
    def onSet(self):
        #from subprocess import call
        #call("notepad ./Project/Sequences/DefaultSequence.py")

        self.editor = QsciScintilla()

        # define the font to use
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        # the font metrics here will help
        # building the margin width later
        fm = QFontMetrics(font)

        ## set the default font of the editor
        ## and take the same font for line numbers
        self.editor.setFont(font)
        self.editor.setMarginsFont(font)

        ## Line numbers
        # conventionnaly, margin 0 is for line numbers
        self.editor.setMarginWidth(0, fm.width("00000") + 5)
        self.editor.setMarginLineNumbers(0, True)

        ## Edge Mode shows a red vetical bar at 80 chars
        self.editor.setEdgeMode(QsciScintilla.EdgeLine)
        self.editor.setEdgeColumn(80)
        self.editor.setEdgeColor(QColor("#FF0000"))

        ## Folding visual : we will use boxes
        self.editor.setFolding(QsciScintilla.BoxedTreeFoldStyle)

        ## Braces matching
        self.editor.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        ## Editing line color
        self.editor.setCaretLineVisible(True)
        self.editor.setCaretLineBackgroundColor(QColor("#CDA869"))

        ## Margins colors
        # line numbers margin
        self.editor.setMarginsBackgroundColor(QColor("#333333"))
        self.editor.setMarginsForegroundColor(QColor("#CCCCCC"))

        # folding margin colors (foreground,background)
        self.editor.setFoldMarginColors(QColor("#99CC66"), QColor("#333300"))

        ## Choose a lexer
        lexer = QsciLexerPython()
        lexer.setDefaultFont(font)
        api = QsciStrictAPIs(lexer)
        api.prepare()
        lexer.setDefaultFont(font)
        self.editor.setLexer(lexer)
        self.editor.setMinimumSize(1024, 768)
        self.editor.show()
        ## Show this file in the editor
        text = open("./Project/Sequences/DefaultSequence.py").read()
        self.editor.setText(text)
Пример #4
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)
Пример #5
0
 def __init__(self):
     super().__init__(flags=0)
     self.code = QsciScintilla()
     # self.code.setTabStopWidth(4)
     self.code.setTabWidth(4)
     self.code.setMarginWidth(1, 100)
     self.code.setMarginLineNumbers(1, True)
     self.code.setAutoIndent(True)
     self.font = QFont('Courier New', 18)
     self.code.setFont(self.font)
     self.code.setMinimumSize(1024, 768)
     self.locations = {}
     self.debug_mode = False
     self.setCentralWidget(self.code)
     self.pane_output = QDockWidget('Output', self)
     self.output = QTextEdit(self.pane_output)
     self.pane_memory = QDockWidget('Memory', self)
     self.memory_list = QListWidget(self.pane_memory)
     self.memory = [0] * 65536
     self.setup_menu()
     self.setup_panes()
     self.cfg = Config()
     self.directory = self.cfg.get('directory')
     self.filename = self.cfg.get('filename')
     if self.filename:
         self.open_file(self.filename)
     self.mega = Mega()
     self.update_memory_list()
     self.load_settings()
Пример #6
0
    def findPath(self, index):
        path = self.sender().model().filePath(index)

        if os.path.isfile(path):
            global name
            FormWidget.filepath.append(path)
            name = os.path.basename(path)
            for i in range(self.tab.count()):
                if name == self.tab.tabText(i):
                    self.tab.removeTab(i)
                    break

            newEdit = QsciScintilla()
            self.checkExtensionToHighlight(path, newEdit)
            newEdit.setFont(QFont('Times', 10))
            newEdit.setMarginType(0, QsciScintilla.NumberMargin)
            newEdit.setMarginWidth(0, '00000000')
            try:
                newEdit.setText(open(path).read())
                newEdit.setBraceMatching(QsciScintilla.SloppyBraceMatch)
                newEdit.setAutoCompletionCaseSensitivity(False)
                newEdit.setAutoCompletionReplaceWord(False)
                newEdit.setAutoCompletionSource(QsciScintilla.AcsDocument)
                newEdit.setAutoCompletionThreshold(1)
                self.tab.insertTab(0, newEdit, QIcon('icon.png'),
                                   os.path.basename(path))
                self.tab.setCurrentIndex(0)
            except:
                QMessageBox.warning(self, "Warning", "Unsupported file type",
                                    QMessageBox.Ok)
Пример #7
0
 def openFile(self):
     files = QFileDialog.getOpenFileNames(self, "Open", FormWidget.path)
     if files[0]:
         FormWidget.filepath = files[0]
         FormWidget.path = os.path.dirname(files[0][0])
         self.form_widget.tree.setRootIndex(
             self.form_widget.model.index(FormWidget.path))
         for i in files[0]:
             n = os.path.basename(i)
             for j in range(self.form_widget.tab.count()):
                 if n == self.form_widget.tab.tabText(j):
                     self.form_widget.tab.removeTab(j)
                     break
             newEdit = QsciScintilla()
             newEdit.setFont(QFont('Times', 10))
             newEdit.setMarginType(0, QsciScintilla.NumberMargin)
             newEdit.setMarginWidth(0, '00000000')
             self.form_widget.checkExtensionToHighlight(i, newEdit)
             try:
                 newEdit.setText(open(i).read())
                 newEdit.setBraceMatching(QsciScintilla.SloppyBraceMatch)
                 newEdit.setAutoCompletionCaseSensitivity(False)
                 newEdit.setAutoCompletionReplaceWord(False)
                 newEdit.setAutoCompletionSource(QsciScintilla.AcsDocument)
                 newEdit.setAutoCompletionThreshold(1)
                 self.form_widget.tab.insertTab(0, newEdit,
                                                QIcon('icon.png'), n)
                 self.form_widget.tab.setCurrentIndex(0)
             except:
                 QMessageBox.warning(self, 'Warning',
                                     'Unsupported file type',
                                     QMessageBox.Ok)
Пример #8
0
    def Setup(self):
        # Setting the size to be fixed
        self.setFixedSize(800, 800)
        # adding the the custom editor of QsciScintilla
        self.editor = QsciScintilla()
        self.editor.setGeometry(25, 25, 750, 750)
        # adding text to the ditro
        self.editor.append("print('Hello World!') # this is just a test")
        # this is i am not sure yet but i think its for the syntax
        self.python_syntax = QsciLexerPython()
        self.editor.setLexer(self.python_syntax)
        self.editor.setUtf8(True)  # Set encoding to UTF-8
        # setting editor position

        # adding font
        self.Font = QFont()
        # adding text size
        self.Font.setPointSize(16)
        # applying font
        self.editor.setFont(self.Font)  # Will be overridden by lexer!
        # adding the editor to te form
        self.layout().addWidget(self.editor)

        # showing ui
        self.show()
Пример #9
0
    def __init__(self, name, currentValue):
        super(QDialog, self).__init__()
        self.setWindowTitle(name)
        self.resize(800, 600)
        self.codeEdit = QsciScintilla()
        self.codeEdit.setText(currentValue)
        fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
        self.codeEdit.setFont(fixedWidthFont)
        fontmetrics = QFontMetrics(fixedWidthFont)
        self.codeEdit.setMarginWidth(0, fontmetrics.width("000"))
        self.codeEdit.setMarginLineNumbers(0, True)
        self.codeEdit.setMarginsBackgroundColor(QColor("#cccccc"))

        self.codeEdit.setBraceMatching(QsciScintilla.SloppyBraceMatch)
        self.codeEdit.setCaretLineVisible(True)
        self.codeEdit.setCaretLineBackgroundColor(QColor("#ffe4e4"))
        lexer = QsciLexerPython()
        lexer.setDefaultFont(fixedWidthFont)
        self.codeEdit.setLexer(lexer)
        self.codeEdit.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
        self.codeEdit.setUtf8(True)

        self.codeEdit.setTabWidth(4)
        self.codeEdit.setIndentationsUseTabs(True)
        self.codeEdit.setIndentationGuides(True)
        self.codeEdit.setTabIndents(True)
        self.codeEdit.setAutoIndent(True)

        self.cancelButton = QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.cancel)
        self.acceptButton = QPushButton('Accept')
        self.acceptButton.clicked.connect(self.accept)

        self.pythonButton = QRadioButton('Python')
        self.pythonButton.setChecked(True)
        self.pythonButton.clicked.connect(self.pythonClicked)
        self.cppButton = QRadioButton('C++')
        self.cppButton.clicked.connect(self.cppClicked)

        hLayout0 = QHBoxLayout()
        hLayout0.addWidget(self.pythonButton)
        hLayout0.addWidget(self.cppButton)
        container0 = QWidget()
        container0.setLayout(hLayout0)

        verticalLayout = QVBoxLayout()
        verticalLayout.addWidget(container0)
        verticalLayout.addWidget(self.codeEdit)

        container = QWidget()
        hLayout = QHBoxLayout()
        hLayout.addWidget(self.cancelButton)
        hLayout.addWidget(self.acceptButton)
        container.setLayout(hLayout)

        verticalLayout.addWidget(container)
        self.setLayout(verticalLayout)

        self.language = 'python'
Пример #10
0
    def createNewSourceTab(self, source_file):

        editor = QsciScintilla()
        # TABS & READ ONLY
        # ------------------
        editor.setIndentationsUseTabs(False)
        editor.setTabWidth(2)
        editor.setReadOnly(True)

        # CARET
        # -----
        editor.setCaretLineVisible(True)
        editor.setCaretWidth(2)
        editor.setCaretLineBackgroundColor(QColor("#1f0000ff"))

        # MARGIN
        # ------
        editor.setMarginsForegroundColor(QColor("#ff888888"))

        # - LineNumber - margin 0
        editor.setMarginType(0, QsciScintilla.NumberMargin)

        # - LeakMarker - margin 1
        editor.setMarginType(1, QsciScintilla.SymbolMargin)
        editor.setMarginSensitivity(1, True)

        # SIGNALS
        # editor.marginClicked.connect(self.marginLeftClick)

        # INDICATORS
        editor.indicatorDefine(QsciScintilla.HiddenIndicator, 0)
        editor.setIndicatorHoverStyle(QsciScintilla.ThickCompositionIndicator,
                                      0)
        editor.setIndicatorForegroundColor(QColor("#00f"), 0)
        editor.setIndicatorHoverForegroundColor(QColor("#00f"), 0)
        editor.setIndicatorDrawUnder(True, 0)

        # LEXER
        # -----
        lexer = QsciLexerCPP(editor)
        self.lexer_list.append(lexer)
        lexer.setFont(QFont("monospace", default_font_size, QFont.Normal), 0)
        editor.setLexer(lexer)
        self.setSourceCode(editor, source_file)

        # MARGIN AND MARKERS
        # ------
        self.recomputeMarkers(editor)

        tab_index = self.addTab(editor, source_file.name.split("/")[-1])
        return tab_index
Пример #11
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.qfont = QFont()
        self.qfont.setPointSize(11)

        self.qscintilla = QsciScintilla()
        self.qscintilla.setWrapMode (QsciScintilla.SC_WRAP_NONE)
        self.ui.verticalLayout.addWidget(self.qscintilla)
        self.qscintilla.textChanged.connect(self.acpiTblCntChanged)
        self.qscintilla.setFont(self.qfont)

        self.ui.pushButton.clicked.connect(self.compilePushButton)
        self.ui.pushButton.setEnabled(False)
        self.ui.pushButton_2.clicked.connect(self.loadPushButton)
        self.ui.pushButton_2.setEnabled(False)
        self.ui.pushButton_3.clicked.connect(self.debugOnPushButton)
        self.ui.pushButton_4.clicked.connect(self.debugOffPushButton)
        self.ui.pushButton_5.clicked.connect(self.searchPushButton)
        self.ui.checkBox.stateChanged.connect(self.woCheckBox)
        self.ui.checkBox_2.stateChanged.connect(self.csCheckBox)

        self.wo, self.cs = False, False

        self.msgBox = QMessageBox()

        # Show ACPI tbl in QListView
        self.acpiRegTblList = GetEnumKeyList (winreg.HKEY_LOCAL_MACHINE, ACPI_REG_KEY_PATH)
        self.ctnRegTblList = list()
        # Collect needed external control method AML
        for regTbl in self.acpiRegTblList:
            if re.match(r'SSD.|DSDT', regTbl):
                    self.ctnRegTblList.append (regTbl)

        # Extract AMLs
        for regTbl in self.ctnRegTblList:
            subprocess.run ([aslExePath, '/nologo', '/tab=' + regTbl, '/c'], encoding='utf-8', capture_output=False)

        self.extCtnAmlList = [f for f in cfg['EXT_CTN_AML_DIR'] if os.path.exists(f)]

        acpiSlm = QStringListModel()
        acpiSlm.setStringList(self.ctnRegTblList)
        self.ui.listView.setModel(acpiSlm)
        self.ui.listView.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)

        self.tblName = str()
        self.acpiModelIndex = QModelIndex()

        self.ui.listView.clicked.connect(self.clickedListView)
Пример #12
0
def create_qscintilla_code_view():
    """ Create a QScintilla based view containing a copy of this source code.
    """

    from PyQt5.Qsci import QsciLexerPython, QsciScintilla

    view = QsciScintilla()
    view.setReadOnly(True)
    view.setUtf8(True)
    view.setLexer(QsciLexerPython())
    view.setFolding(QsciScintilla.PlainFoldStyle)
    view.setText(get_source_code())

    return view
Пример #13
0
    def addEmptyTab(self):
        newTab = QtWidgets.QWidget()
        self.tabWidget.addTab(newTab, 'New Script')
        newTab.setToolTip('New Script')
        self.tabWidget.setCurrentWidget(newTab)

        tabGrid = QtWidgets.QGridLayout(newTab)
        tabGrid.setContentsMargins(2, 2, 2, 2)
        newSciInput = QsciScintilla(newTab)
        newSciInput.setFrameShape(QtWidgets.QFrame.Box)
        tabGrid.addWidget(newSciInput, 0, 0, 1, 1)
        self._setQSci(newSciInput)
        newSciInput.setText('')
        newSciInput.setFocus()
Пример #14
0
 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()
Пример #15
0
    def __init__(self):
        """ Invoked to return the default editor widget. """

        from PyQt5.Qsci import QsciLexerPython, QsciScintilla

        editor = QsciScintilla()

        # Configure the editor for Python.
        editor.setUtf8(True)
        editor.setLexer(QsciLexerPython(editor))
        editor.setFolding(QsciScintilla.PlainFoldStyle, 1)
        editor.setIndentationGuides(True)
        editor.setIndentationWidth(4)

        self.editor = editor
Пример #16
0
 def newFile(self):
     text, ok = QInputDialog.getText(self, 'New', 'Enter File name:')
     if ok:
         newEdit = QsciScintilla()
         newEdit.setMarginType(0, QsciScintilla.NumberMargin)
         newEdit.setMarginWidth(0, '00000000')
         newEdit.setBraceMatching(QsciScintilla.SloppyBraceMatch)
         newEdit.setAutoCompletionCaseSensitivity(False)
         newEdit.setAutoCompletionReplaceWord(False)
         newEdit.setAutoCompletionSource(QsciScintilla.AcsDocument)
         newEdit.setAutoCompletionThreshold(1)
         self.form_widget.checkExtensionToHighlight(text, newEdit)
         newEdit.setFont(QFont('Times', 10))
         self.form_widget.tab.insertTab(0, newEdit, QIcon('icon.png'), text)
         self.form_widget.tab.setCurrentIndex(0)
Пример #17
0
    def createNewAsmTab(self, file_path, asm_dump):
        editor = QsciScintilla()
        # TABS & READ ONLY
        # ------------------
        editor.setIndentationsUseTabs(False)
        editor.setTabWidth(2)
        editor.setReadOnly(True)

        # CARET
        # -----
        editor.setCaretLineVisible(True)
        editor.setCaretWidth(2)
        editor.setCaretLineBackgroundColor(QColor("#1fff0000"))

        # MARGIN
        # ------
        editor.setMarginsForegroundColor(QColor("#ff888888"))

        # - LeakMarker - margin 1
        editor.setMarginType(1, QsciScintilla.SymbolMargin)
        editor.setMarginSensitivity(1, True)

        # SIGNALS
        # editor.marginClicked.connect(self.marginLeftClick)

        # INDICATORS
        editor.indicatorDefine(QsciScintilla.TextColorIndicator, 0)
        editor.setIndicatorHoverStyle(QsciScintilla.ThickCompositionIndicator,
                                      0)
        editor.setIndicatorForegroundColor(QColor("#f00"), 0)
        editor.setIndicatorHoverForegroundColor(QColor("#f00"), 0)
        editor.setIndicatorDrawUnder(True, 0)

        # FONT
        # ----
        editor.setFont(QFont("monospace", default_font_size, QFont.Normal))

        # EDITOR CONTENT
        # --------------
        editor.append(asm_dump)

        # MARGIN AND MARKERS
        # ------
        self.recomputeMarkers(editor)

        tab_index = self.addTab(editor, file_path.split("/")[-1])
        return tab_index
Пример #18
0
    def addNewTab(self, scriptFile):
        print("Loading tab..." + scriptFile)
        fileName = os.path.basename(scriptFile)

        newTab = QtWidgets.QWidget()
        self.tabWidget.addTab(newTab, fileName)
        newTab.setToolTip(scriptFile)
        self.tabWidget.setCurrentWidget(newTab)

        tabGrid = QtWidgets.QGridLayout(newTab)
        tabGrid.setContentsMargins(2, 2, 2, 2)
        newSciInput = QsciScintilla(newTab)
        newSciInput.setFrameShape(QtWidgets.QFrame.Box)
        tabGrid.addWidget(newSciInput, 0, 0, 1, 1)
        self._setQSci(newSciInput)
        data = str(self.ttls.fileContent(scriptFile))
        newSciInput.setText(data)
Пример #19
0
    def createTabWidget(self, code, textLexer: QsciLexer):
        tabWidget = QWidget()
        # 垂直布局
        layout = WidgetUtil.createVBoxLayout()
        # 设置布局方式
        tabWidget.setLayout(layout)

        editor = QsciScintilla(tabWidget)
        editor.setLexer(textLexer)

        # 行号提示
        editor.setMarginType(0, QsciScintilla.NumberMargin)  # 设置编号为1的页边显示行号。
        editor.setMarginLineNumbers(0, True)  # 对该页边启用行号
        editor.setMarginWidth(0, 30)  # 设置页边宽度
        editor.setText(code)
        editor.SendScintilla(QsciScintilla.SCI_SETCODEPAGE, QsciScintilla.SC_CP_UTF8)  # 设置编码为UTF-8

        editor.setReadOnly(True)

        # 添加控件到布局中
        layout.addWidget(editor)
        return tabWidget
Пример #20
0
    def setDefaultShortcuts(self):
        reply = QtWidgets.QMessageBox.warning(self, "Default Keymap",
                                          "Setting keymap to default will wipe away your current keymap.\n\nProceed?",
                                          QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
        if reply == QtWidgets.QMessageBox.Yes:
            for key, value in self.useData.DEFAULT_SHORTCUTS['Ide'].items():
                default = self.useData.DEFAULT_SHORTCUTS['Ide'][key]
                self.useData.CUSTOM_SHORTCUTS['Ide'][key] = default

            sc = QsciScintilla()
            standardCommands = sc.standardCommands()

            for key, value in self.useData.DEFAULT_SHORTCUTS['Editor'].items():
                default = self.useData.DEFAULT_SHORTCUTS['Editor'][key]
                command = standardCommands.find(default[1])
                keyValue = command.key()
                self.useData.CUSTOM_SHORTCUTS[
                    'Editor'][key] = [default[0], keyValue]
            self.save()
            self.useData.loadKeymap()
            self.updateShortcutsView()
        else:
            return
Пример #21
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
Пример #22
0
 def abrir_archivo(self):
     try:
         dialog = QtWidgets.QFileDialog().getOpenFileName(
             None, ' Open document', r"C:\Users\\", "All Files (*)")
         ruta = dialog[0]
         trozos = ruta.split("/")
         name = trozos[len(trozos) - 1]
         self.pestañas[name] = ruta
         file = open(ruta, 'r')
         codigo = file.read()
         tab = QtWidgets.QWidget()
         area = QsciScintilla(tab)
         area.setGeometry(QtCore.QRect(10, 10, 631, 371))
         area.setObjectName("plainTextEdit")
         area.setFont(self.__myFont)
         area.setMarginType(0, QsciScintilla.NumberMargin)
         area.setMarginWidth(0, "00000")
         area.setMarginsForegroundColor(QtGui.QColor("#0C4B72"))
         area.markerDefine(QsciScintilla.RightArrow, 0)
         area.setMarginSensitivity(0, True)
         area.setWrapMode(QsciScintilla.WrapWord)
         area.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
         area.setWrapIndentMode(QsciScintilla.WrapIndentIndented)
         area.setEolMode(QsciScintilla.EolWindows)
         area.setEolVisibility(False)
         area.setWrapVisualFlags(QsciScintilla.WrapFlagByText)
         area.marginClicked.connect(self.on_margin_clicked)
         __lexer = QsciLexerCPP(area)
         area.setLexer(__lexer)
         self.editor.addTab(tab, "")
         area.setText(codigo)
         area.setObjectName("area")
         self.editor.addTab(tab, name)
         file.close()
     except:
         em = QtWidgets.QErrorMessage(self.mw)
         em.showMessage("Error al abrir {0}".format(name))
Пример #23
0
    def __init__(self,
                 layout_dir: str,
                 title: str,
                 initial_value: str = '',
                 lexer=''):
        super().__init__(layout_dir)
        self.on_check_callback = None

        self.prefix = QLabel(text=title)

        entryLayout = QHBoxLayout()
        entryLayout.setContentsMargins(0, 0, 0, 0)
        self.ctrl = QsciScintilla()
        if lexer == 'python':
            self.ctrl.setLexer(QsciLexerPython())
        self.ctrl.setText(initial_value)
        # self.ctrl.textChanged.connect(self.ontext)

        # self.postfix = lab_unit = QLabel(text=unit)

        self.central_layout.addWidget(self.prefix)
        self.central_layout.addLayout(entryLayout)
        entryLayout.addWidget(self.ctrl)
        self.set_value(initial_value)
Пример #24
0
    def __init__(self, path, name, label_name, json, parent=None):
        super(JsonEditorDlg, self).__init__(parent)
        self.setWindowTitle("Json Editor")
        self._path = path
        self._name = name
        self._label_name = label_name
        self.orig_text = json

        self._label_file = QtWidgets.QLabel(label_name + ": " + name, self)
        self._save_button = QtWidgets.QPushButton("Save ...", self)
        self._save_button.clicked.connect(self._save_file)
        self._save_as_button = QtWidgets.QPushButton("Save as...", self)
        self._save_as_button.clicked.connect(self._save_as_file)
        self._cancel_button = QtWidgets.QPushButton("Cancel", self)
        self._cancel_button.clicked.connect(self._cancel)

        self._editor = QsciScintilla(self)

        # Set Yaml lexer
        self._editor.lexer = QsciLexerJavaScript()
        self._editor.setLexer(self._editor.lexer)
        self._editor.setMinimumSize(600, 450)
        self._editor.setText(json)

        appearance.set_default_appearence(self._editor)

        button_layout = QtWidgets.QHBoxLayout()
        button_layout.addWidget(self._label_file)
        button_layout.addWidget(self._save_button)
        button_layout.addWidget(self._save_as_button)
        button_layout.addWidget(self._cancel_button)

        layout = QtWidgets.QVBoxLayout(self)
        layout.addLayout(button_layout)
        layout.addWidget(self._editor)
        self.setLayout(layout)
Пример #25
0
    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()
        color: $text;
        background-color: rgb(255,255,20);
    }
    /* ======================== */
    /* MENU==================== */
    QMenuBar[aa="bbb"], #xxxx .abcc {
        background-color: "red";
        aaa: 'bbb';
    }

    QMenuBar::item
    {
        background: transparent;
    }

    QMenuBar::item:selected
    {
        background:#8bf;
        border: 1px solid #8bf;
    }
    """.replace("\n", "\r\n")

    app = QApplication(sys.argv)
    win = QsciScintilla()
    win.setText(myCodeSample)
    l = QsciLexerQSS(win)
    win.setLexer(l)
    win.show()
    QApplication.setStyle(QStyleFactory.create('Fusion'))
    sys.exit(app.exec_())
Пример #27
0
#!/usr/bin/env python

# I failed to install correct versoin of qscintilla using pip -
# only `python-qscintilla-qt 2.11.4-1` package from aur worked
# correctly
from PyQt5.Qsci import QsciScintilla
from PyQt5.QtWidgets import QApplication

app = QApplication([])

ed = QsciScintilla()

ed.setText('insert <-\nsome <-\ntext <-\n')
ed.show()

# typing should insert in all selections at the same time
ed.SendScintilla(ed.SCI_SETADDITIONALSELECTIONTYPING, 1)

# do multiple selections
offset = ed.positionFromLineIndex(0, 7)  # line-index to offset
ed.SendScintilla(ed.SCI_SETSELECTION, offset, offset)
# using the same offset twice selects no characters, hence a cursor

offset = ed.positionFromLineIndex(1, 5)
ed.SendScintilla(ed.SCI_ADDSELECTION, offset, offset)

offset = ed.positionFromLineIndex(2, 5)
ed.SendScintilla(ed.SCI_ADDSELECTION, offset, offset)

app.exec_()
Пример #28
0
    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 __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()
Пример #30
0
    def __init__(self, parent=None, lineNumberOn=False):
        super(highlightEditor, self).__init__()

        self.editor = QsciScintilla(parent)
        font = QFont()
        font.setFamily("Consolas")
        font.setPointSize(12)
        font.setFixedPitch(True)
        self.editor.setFont(font)
        self.editor.setObjectName("editor")

        self.editor.setUtf8(True)
        self.editor.setMarginsFont(font)
        if lineNumberOn:
            self.editor.setMarginWidth(
                0,
                len(str(len(self.editor.text().split('\n')))) * 20)
        self.editor.setMarginLineNumbers(0, lineNumberOn)

        self.editor.setBraceMatching(QsciScintilla.StrictBraceMatch)

        self.editor.setIndentationsUseTabs(True)
        self.editor.setIndentationWidth(4)
        self.editor.setTabIndents(True)
        self.editor.setAutoIndent(True)
        self.editor.setBackspaceUnindents(True)
        self.editor.setTabWidth(4)

        self.editor.setCaretLineVisible(True)
        self.editor.setCaretLineBackgroundColor(QColor('#DCDCDC'))

        self.editor.setIndentationGuides(True)

        self.editor.setFolding(QsciScintilla.PlainFoldStyle)
        self.editor.setMarginWidth(2, 12)

        self.editor.markerDefine(QsciScintilla.Minus,
                                 QsciScintilla.SC_MARKNUM_FOLDEROPEN)
        self.editor.markerDefine(QsciScintilla.Plus,
                                 QsciScintilla.SC_MARKNUM_FOLDER)
        self.editor.markerDefine(QsciScintilla.Minus,
                                 QsciScintilla.SC_MARKNUM_FOLDEROPENMID)
        self.editor.markerDefine(QsciScintilla.Plus,
                                 QsciScintilla.SC_MARKNUM_FOLDEREND)

        self.editor.setMarkerBackgroundColor(
            QColor("#FFFFFF"), QsciScintilla.SC_MARKNUM_FOLDEREND)
        self.editor.setMarkerForegroundColor(
            QColor("#272727"), QsciScintilla.SC_MARKNUM_FOLDEREND)
        self.editor.setMarkerBackgroundColor(
            QColor("#FFFFFF"), QsciScintilla.SC_MARKNUM_FOLDEROPENMID)
        self.editor.setMarkerForegroundColor(
            QColor("#272727"), QsciScintilla.SC_MARKNUM_FOLDEROPENMID)
        self.editor.setAutoCompletionSource(QsciScintilla.AcsAll)
        self.editor.setAutoCompletionCaseSensitivity(True)
        self.editor.setAutoCompletionReplaceWord(False)
        self.editor.setAutoCompletionThreshold(1)
        self.editor.setAutoCompletionUseSingle(QsciScintilla.AcusExplicit)
        self.lexer = highlight(self.editor)
        self.editor.setLexer(self.lexer)
        self.__api = QsciAPIs(self.lexer)
        autocompletions = keyword.kwlist + []
        for ac in autocompletions:
            self.__api.add(ac)
        self.__api.prepare()
        self.editor.autoCompleteFromAll()

        self.editor.textChanged.connect(self.changed)