2 Copyright (C) 1997-2017 JDERobot Developers Team 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU Library General Public License for more details. 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, see <http://www.gnu.org/licenses/>. 17 Authors : Okan Asik (asik.okan@gmail.com) 21 from PyQt5.QtWidgets
import QDialog, QTextEdit, QPushButton, QVBoxLayout, \
22 QWidget, QHBoxLayout, QApplication, QRadioButton
23 from PyQt5.QtCore
import pyqtSignal
24 from PyQt5.QtGui
import QFontDatabase, QColor, QFontMetrics
25 from PyQt5.Qsci
import QsciScintilla, QsciLexerPython, QsciLexerCPP
28 codeChanged = pyqtSignal(
'QString')
32 self.setWindowTitle(name)
35 self.codeEdit.setText(currentValue)
36 fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
37 self.codeEdit.setFont(fixedWidthFont)
38 fontmetrics = QFontMetrics(fixedWidthFont)
39 self.codeEdit.setMarginWidth(0, fontmetrics.width(
"000"))
40 self.codeEdit.setMarginLineNumbers(0,
True)
41 self.codeEdit.setMarginsBackgroundColor(QColor(
"#cccccc"))
43 self.codeEdit.setBraceMatching(QsciScintilla.SloppyBraceMatch)
44 self.codeEdit.setCaretLineVisible(
True)
45 self.codeEdit.setCaretLineBackgroundColor(QColor(
"#ffe4e4"))
46 lexer = QsciLexerPython()
47 lexer.setDefaultFont(fixedWidthFont)
48 self.codeEdit.setLexer(lexer)
49 self.codeEdit.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
50 self.codeEdit.setUtf8(
True)
52 self.codeEdit.setTabWidth(4)
53 self.codeEdit.setIndentationsUseTabs(
True)
54 self.codeEdit.setIndentationGuides(
True)
55 self.codeEdit.setTabIndents(
True)
56 self.codeEdit.setAutoIndent(
True)
59 self.cancelButton.clicked.connect(self.
cancel)
61 self.acceptButton.clicked.connect(self.
accept)
64 self.pythonButton.setChecked(
True)
67 self.cppButton.clicked.connect(self.
cppClicked)
69 hLayout0 = QHBoxLayout()
72 container0 = QWidget()
73 container0.setLayout(hLayout0)
75 verticalLayout = QVBoxLayout()
76 verticalLayout.addWidget(container0)
77 verticalLayout.addWidget(self.
codeEdit)
80 hLayout =QHBoxLayout()
83 container.setLayout(hLayout)
85 verticalLayout.addWidget(container)
86 self.setLayout(verticalLayout)
94 self.codeChanged.emit(self.codeEdit.text())
98 fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
99 lexer = QsciLexerPython()
100 lexer.setDefaultFont(fixedWidthFont)
101 self.codeEdit.setLexer(lexer)
105 fixedWidthFont = QFontDatabase.systemFont(QFontDatabase.FixedFont)
106 lexer = QsciLexerCPP()
107 lexer.setDefaultFont(fixedWidthFont)
108 self.codeEdit.setLexer(lexer)
111 if __name__ ==
'__main__':
112 app = QApplication(sys.argv)
def __init__(self, name, currentValue)