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 __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()
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()
def __init__(self, parent=None): QsciScintilla.__init__(self, parent) self.setUtf8(True) self.setFont(QFont('Consolas', 10)) self.setLexer(QsciLexerPython()) self.setMarginLineNumbers(1, True) self.setTabWidth(4) self.setAutoIndent(True) self.setIndentationGuides(True) self.setIndentationsUseTabs(False) self.setBackspaceUnindents(True) self.setWrapMode(QsciScintilla.WrapWord) self.setWrapIndentMode(QsciScintilla.WrapIndentIndented) self.setBraceMatching(QsciScintilla.SloppyBraceMatch) self.setFolding(QsciScintilla.PlainFoldStyle) self.context_menu = None self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.onContextMenuRequested) self.linesChanged.connect( lambda: self.setMarginWidth(1, ' %d' % self.lines()) )
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)
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)
def keyPressEvent(self, ev): """ Re-implemented to handle the user input a key at a time. @param ev key event (QKeyEvent) """ txt = ev.text() key = ev.key() ctrl = ev.modifiers() & Qt.ControlModifier if (ctrl): QsciScintilla.keyPressEvent(self, ev) elif (self.keymap.has_key(key)): self.keymap[key]() # See it is text to insert. elif self.__isCursorOnLastLine() and txt.length(): QsciScintilla.keyPressEvent(self, ev) self.incrementalSearchActive = True if (txt == '.'): self.__showDynCompletion() else: ev.ignore()
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'
def __init__(self, sci: QsciScintilla, comment_string: str): self.sci = sci self.comment_string = comment_string self.line_ending = "\n" sci.SendScintilla(self.sci.SCI_SETMULTIPLESELECTION, 1) sci.SendScintilla(self.sci.SCI_SETADDITIONALSELECTIONTYPING, True) QShortcut(QKeySequence(Qt.CTRL + Qt.Key_7), self.sci, self.toggle_commenting)
def _findFirst(self, query: FindQuery): opts = query.options args = (query.expression, opts.regularExpression, opts.caseSensitive, opts.wholeWords) kwargs = {'forward': query.direction == FindDirection.Forward, 'show': True, 'cxx11': True} if opts.inSelection: result = QsciScintilla.findFirstInSelection(self, *args, **kwargs) else: result = QsciScintilla.findFirst(self, *args, True, **kwargs) query.callback(result)
def keyPressEvent(self, event): if event.key() == Qt.Key_Space: if QApplication.keyboardModifiers() == Qt.ControlModifier: self.autoCompleteFromAll() return QsciScintilla.keyPressEvent(self, event) self.complete.line, self.complete.column = self.getCursorPosition() self.complete.text = self.text() self.setMarginWidth(0, len(str(len(self.text().split('\n')))) * 20) # if event.key() not in [Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right]: # if not self.complete.started: # self.complete.start() self.key_pressed.emit()
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)
def _key_pressed(self, event): """ Handle KeyPressed event We only care about CTRL-S in order to save changes :param event: key event """ QsciScintilla.keyPressEvent(self._code_editor, event) if event.key() in [QtCore.Qt.Key_S, QtCore.Qt.Key_Save]: modifiers = QApplication.keyboardModifiers() if modifiers == QtCore.Qt.ControlModifier and self.is_modified: logger.debug("Saving...") self.on_save_changes() self.key_pressed_event(event)
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 __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'
class TextEdit(BaseParamWidget): 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) # entryLayout.addWidget(self.postfix) def get_value(self): return self.ctrl.text() def set_value(self, value: str): self.ctrl.setText(value)
def key_press_event(self, event): self.update_dirty() if self.editor.__class__.__name__ == "LineTextWidget": return self.editor.edit.keyReleaseEvent(event) # When using PySide without QSciScintilla QsciScintilla.keyPressEvent(self.editor, event) linenr, pos_in_line = self.editor.getCursorPosition() line = str(self.editor.text(linenr)[:pos_in_line]) if event.key() == Qt.Key_F1: try: self.parent.show_documentation(getattr(self.scriptRunner, str(self.editor.selectedText()))) except AttributeError: pass if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return: for tip in self.autocomplete_lst: try: if line.endswith(tip[:tip.index('(') ]): self.editor.insert(tip[tip.index('('):]) parent, residual = self.scriptRunner.split_line(line) self.parent.show_documentation(self.scriptRunner.get_function_dict(parent, residual)[residual]) return except ValueError: pass if event.key() < 100 or event.key() in [Qt.Key_Backspace, Qt.Key_Shift]: linenr, pos_in_line = self.editor.getCursorPosition() line = str(self.editor.text(linenr)[:pos_in_line]) lst = self.scriptRunner.get_autocomplete_list(line) if lst is not None: self.api.clear() list(map(self.api.add, lst)) self.api.prepare() if len(lst) > 0: self.autocomplete_lst = lst self.editor.autoCompleteFromAll() shift_event = QKeyEvent(QEvent.KeyPress, Qt.Key_Shift, Qt.NoModifier) QsciScintilla.keyPressEvent(self.editor, shift_event) # show autocomplete list
def fillIndicatorRange(self, lineFrom, indexFrom, lineTo, indexTo, indic, value=1): indic = self._indicatorToId(indic) if indic < 0: return QsciScintilla.fillIndicatorRange(self, lineFrom, indexFrom, lineTo, indexTo, indic) offset_start = self.positionFromLineIndex(lineFrom, indexFrom) offset_end = self.positionFromLineIndex(lineTo, indexTo) self._setIndicatorCurrent(indic) self._setIndicatorValue(value) self._fillIndicatorRange(offset_start, offset_end - offset_start)
def __init__(self, parent=None): QsciScintilla.__init__(self, parent) self.complete = AutoComplete() self.complete.prepare.connect(self.update_completes) self.lexer = text_lexer(self) self.setLexer(self.lexer) self.api = QsciAPIs(self.lexer) self.setAutoIndent(True) self.setMarginLineNumbers(0, True) self.setEdgeMode(QsciScintilla.EdgeLine) self.setEdgeColumn(79) self.setEdgeColor(QColor(0, 0, 0)) """ self.setIndentationsUseTabs(True) self.setIndentationWidth(get_configs()['tab_width']) self.setTabWidth(get_configs()['tab_width']) self.setTabIndents(get_configs()['indent_with_tabs']) self.setBackspaceUnindents(True) self.setCaretLineVisible(True) self.setIndentationGuides(True) self.setCaretForegroundColor(QColor(get_configs()['cursor_color'])) self.setCaretLineBackgroundColor(QColor(get_configs()['line_background_color'])) self.setCaretWidth(6) self.setWrapMode(QsciScintilla.WrapNone if not get_configs()['text_wrap'] else QsciScintilla.WrapWhitespace) self.setEolMode(get_eol_mode(get_configs()['eol_mode'])) # self.setMarginsForegroundColor(QColor("#ff888888")) """ self.setMarginWidth(0, len(str(len(self.text().split('\n')))) * 20) self.setFolding(QsciScintilla.PlainFoldStyle) self.setAutoCompletionSource(QsciScintilla.AcsAll) self.setAutoCompletionCaseSensitivity(True) self.setAutoCompletionReplaceWord(True) self.autoCompleteFromAll() self.setAutoCompletionThreshold(1) self.setAutoCompletionSource(QsciScintilla.AcsAll) self.setUtf8(True) self.setBraceMatching(QsciScintilla.StrictBraceMatch) self.setMatchedBraceForegroundColor( QColor(self.lexer.styles[Name.Decorator])) self.setMatchedBraceBackgroundColor(RGB(0, 255, 0).to_pyqt_color()) self.setCallTipsVisible(-1)
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()
def keyPressEvent(self, event): """ Reimplemented to create a console-like interface. """ line, index = self.getCursorPosition() key = event.key() ctrl = event.modifiers() & QtCore.Qt.ControlModifier alt = event.modifiers() & QtCore.Qt.AltModifier shift_down = event.modifiers() & QtCore.Qt.ShiftModifier if ctrl: pass elif alt: pass elif key == QtCore.Qt.Key_Backspace: if self.getCursorPosition() == self.blocking_cursor_pos: pass else: QsciScintilla.keyPressEvent(self, event) elif key == QtCore.Qt.Key_Left: if self.getCursorPosition() == self.blocking_cursor_pos: pass else: QsciScintilla.keyPressEvent(self, event) elif key == QtCore.Qt.Key_Up: self.scrollVertical(-1) elif key == QtCore.Qt.Key_Down: self.scrollVertical(1) elif key == QtCore.Qt.Key_Return: # get input text text = self.getText(self.blocking_cursor_pos, self.position("eof")) self.insertInput(text) else: QsciScintilla.keyPressEvent(self, event)
def save_editor_text(self, editor: Qsci.QsciScintilla, file_path: str): """""" if file_path: self.editor_path_map[editor] = file_path i = self.tab.currentIndex() file_name = Path(file_path).name self.tab.setTabText(i, file_name) with open(file_path, "w", encoding="UTF8") as f: f.write(editor.text()) self.update_path_label()
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
def focusNextPrevChild(self, next): """ Reimplemented to stop Tab moving to the next window. While the user is entering a multi-line command, the movement to the next window by the Tab key being pressed is suppressed. @param next next window @return flag indicating the movement """ if next and self.more: return False return QsciScintilla.focusNextPrevChild(self, next)
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)
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)
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)
class BrowserWindow(QWidget): launcherWindow = None logoPixmap = None def __init__(self, launcherWindow, app): super().__init__() self.app = app self.launcherWindow = launcherWindow self.fontSize = 14 self.fontSizeLarge = 24 self.fontSizeSmall = 10 self.setCursor(AppData.cursors['arrow']) self.initUI() def multiple_replace(self, string, rep_dict): pattern = re.compile("|".join([re.escape(k) for k in rep_dict.keys()]), re.M) return pattern.sub(lambda x: rep_dict[x.group(0)], string) def styleEsc(self, string): return self.multiple_replace(string, { '{': '{{', '}': '}}', '@<': '{', '>@': '}' }) def initUI(self): ## pal = QPalette(); ## pal.setColor(QPalette.Background, Qt.black); ## self.setPalette(pal); self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) self.styleTemplate = self.styleEsc(""" QWidget{ background-color: black; border-color: red; border-style: solid; border-width: 1px; border-radius: 0px; font: bold @<fontSize>@px; color: red; padding: 0px; font-family: "Candara"; font-size: @<fontSize:d>@px; } QLabel{ font-size: @<fontSizeLarge:d>@px; border-width: 0px; } QTreeView::item:hover { background: black; border: 1px solid red; } QTreeView::item:selected { border: 1px solid red; color: red; } QTreeView::item:selected:active{ background: black; border: 1px solid red; } QTreeView::item:selected:!active { border: 1px solid red; color: red; } QTreeView::branch:has-siblings:!adjoins-item { border-image: url(Gui/stylesheet-vline.png) 0; } QTreeView::branch:has-siblings:adjoins-item { border-image: url(Gui/stylesheet-branch-more.png) 0; } QTreeView::branch:!has-children:!has-siblings:adjoins-item { border-image: url(Gui/stylesheet-branch-end.png) 0; } QTreeView::branch:has-children:!has-siblings:closed, QTreeView::branch:closed:has-children:has-siblings { border-image: none; image: url(Gui/stylesheet-branch-closed.png); } QTreeView::branch:open:has-children:!has-siblings, QTreeView::branch:open:has-children:has-siblings { border-image: none; image: url(Gui/stylesheet-branch-open.png); } QScrollBar:vertical { border: 2px solid red; background: black; width: 40px; margin: 22px 0 22px 0; } QScrollBar::handle:vertical { background: red; min-height: 20px; } QScrollBar::add-line:vertical { border: 2px red; background: black; height: 20px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical { border: 2px red; background: black; height: 20px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 2px solid black; width: 3px; height: 3px; background: red; } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; } """) self.setStyleSheet( self.styleTemplate.format(fontSize=int(self.fontSize), fontSizeLarge=int(self.fontSizeLarge))) #gridWidget = QWidget(self) #self.gridWidget = gridWidget grid = QGridLayout() #treeMooker = QWidget(self) #treeMooker.setStyleSheet("background-color: transparent;") #treeMooker.setAttribute(Qt.WA_TransparentForMouseEvents) #treeMooker.installEventFilter(self) #treeMookerGrid = QGridLayout() #stack = QStackedLayout() #stack.setStackingMode(QStackedLayout.StackAll) logo = QLabel(self) self.logoPixmap = QPixmap("./Project/Media/Gears.png") logo.setPixmap(self.logoPixmap) logo.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) grid.addWidget(logo, 2, 3, 1, 1) self.titleTemplate = self.styleEsc(''' <p align="left"><strong> <span style='font-size:@<fontSizeLarge>@pt; font-weight:600; color:#ff0000;'>GPU Eye And Retina Stimulation </span></strong><span style='font-size:10pt; font-weight:600; color:#aa0000;'>beta test version 0.4</span></p> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td > <p align="left"><span style='font-size:@<fontSize>@pt; font-weight:600; color:#ff0000;'>László Szécsi</span></p> </td> <td > <p><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'>Budapest University of Technology and Economics</span></p> </td> </tr> <tr> <td > <p align="left"> <span style='font-size:@<fontSize>@pt; font-weight:600; color:#ff0000;'>Péter Hantz</span></p> </td> <td > <p><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'>University of Pécs, Medical School</span></p> </td> </tr> <tr> <td > <p align="left"> <span style='font-size:@<fontSize>@pt; font-weight:600; color:#ff0000;'>Ágota Kacsó</span></p> </td> <td > <p><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'>Budapest University of Technology and Economics</span></p> </td> </tr> <tr> <td > <p align="left"><span style='font-size:@<fontSize>@pt; font-weight:600; color:#ff0000;'>Günther Zeck</span></p> </td> <td > <p><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'>Natural and Medical Sciences Institute Reutlingen</span></p> </td> </tr> <tr> <td > <p align="left"><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'>http://www.gears.vision</span></p> </td> <td > <p><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'>[email protected]</span></p> </td> </tr> </tbody> </table> ''') self.titleLabel = QLabel( self.titleTemplate.format(fontSize=self.fontSize, fontSizeLarge=self.fontSizeLarge, fontSizeSmall=self.fontSizeSmall)) self.titleLabel.setTextFormat(Qt.RichText) self.titleLabel.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) grid.addWidget(self.titleLabel, 1, 3, 1, 1) self.instructionsTemplate = self.styleEsc(''' <p align="left"><strong> <table border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td > <p align="left"><span style='font-size:@<fontSize>@pt; font-weight:600; color:#ff0000;'>Reset tree</span></p> </td> <td > <p><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'>press space</span></p> </td> </tr> <tr> <td > <p align="left"><span style='font-size:@<fontSize>@pt; font-weight:600; color:#ff0000;'>Navigate</span></p> </td> <td > <p><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'>press key for first character</span></p> </td> </tr> <tr> <td > <p align="left"> <span style='font-size:@<fontSize>@pt; font-weight:600; color:#ff0000;'>Change font size</span></p> </td> <td > <p><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'>ctrl+mouse wheel</span></p> </td> </tr> <tr> <td > <p align="left"><span style='font-size:@<fontSize>@pt; font-weight:600; color:#ff0000;'>Edit or configure</span></p> </td> <td > <p><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'>right click tree item</span></p> </td> </tr> <tr> <td > <p align="left"><span style='font-size:@<fontSize>@pt; font-weight:600; color:#ff0000;'>/</span></p> </td> <td > <p><span style='font-size:@<fontSizeSmall>@pt; font-weight:600; color:#aa0000;'> @<emptyFolderOp>@ empty folders</span></p> </td> </tr> </tbody> </table> ''') self.instructionsLabel = QLabel( self.instructionsTemplate.format(fontSize=self.fontSize, fontSizeLarge=self.fontSizeLarge, fontSizeSmall=self.fontSizeSmall, emptyFolderOp='show')) self.instructionsLabel.setStyleSheet(''' QLabel{ border-width: 1px; } ''') self.instructionsLabel.setTextFormat(Qt.RichText) self.instructionsLabel.setAlignment(Qt.AlignHCenter) grid.addWidget(self.instructionsLabel, 3, 1, 1, 1) specs = QLabel(gears.getSpecs()) #self.titleLabel.setTextFormat( Qt.RichText ) self.titleLabel.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) specs.setFocusPolicy(Qt.NoFocus) #specsButton.clicked.connect(self.onSpecs) grid.addWidget(specs, 4, 1, 1, 1) quitButton = QPushButton('Quit') quitButton.setFocusPolicy(Qt.NoFocus) quitButton.clicked.connect(self.onQuit) grid.addWidget(quitButton, 4, 3, 1, 1) #settingsButton = QPushButton('Measurement hardware') #settingsButton.setFocusPolicy(Qt.NoFocus) #settingsButton.clicked.connect(self.onSet) #grid.addWidget(settingsButton, 3, 3, 1, 1) tree = BrowserTree(self.launcherWindow, self) tree.setAttribute(Qt.WA_TransparentForMouseEvents, on=False) self.tree = tree tree.setFocusPolicy(Qt.NoFocus) tree.setHeaderHidden(True) tree.setStyleSheet("background-color: black;") item0 = QTreeWidgetItem(tree) item0.setText(0, 'Sequences') itemMap = dict() itemMap["./Project/Sequences"] = item0 rootPath = "./Project/Sequences" emptyDirs = find_empty_dirs(rootPath) for (path, dirs, files) in os.walk(rootPath): for subdir in dirs: if subdir != "__pycache__": fullPath = os.path.join(path, subdir) #if(rootPath == path): # item0 = QTreeWidgetItem(tree) # itemMap[fullPath] = item0 # item0.setText(0, subdir) #else: item1 = QTreeWidgetItem() itemMap[fullPath] = item1 item1.setText(0, subdir) itemMap[path].addChild(item1) if fullPath in emptyDirs: item1.setText( 1, "gears_folder_not_holding_any_sequence_scripts") item1.setHidden(True) for item in files: if item.endswith('.pyx'): #if(rootPath == path): # item0 = QTreeWidgetItem(tree) # itemMap[os.path.join(path, item)] = item0 # item0.setText(0, item) #else: item1 = QTreeWidgetItem() itemMap[os.path.join(path, item)] = item1 item1.setText(0, item) item1.setText(1, "tags spot spatial temporal") itemMap[path].addChild(item1) item0.setExpanded(True) grid.addWidget(tree, 1, 1, 4, 3, Qt.AlignLeft | Qt.AlignTop) #qbtn = QPushButton('Quit', self) #qbtn.clicked.connect(QCoreApplication.instance().quit) #qbtn.resize(qbtn.sizeHint()) #grid.addWidget(qbtn, 8, 9) #treeMooker.setLayout(treeMookerGrid) #gridWidget.setLayout(grid) #stack.addWidget(treeMooker) #stack.addWidget(gridWidget) self.setLayout(grid) self.setWindowTitle('O\u0398\u03a6O') # self.setWindowIcon(QIcon('web.png')) self.showFullScreen() self.setFixedSize(self.size()) self.tree.setCurrentIndex(self.tree.model().index(0, 0)) def keyPressEvent(self, e): if e.key() == Qt.Key_Escape or e.text() == 'q': box = QMessageBox(self) QGuiApplication.setOverrideCursor(AppData.cursors['arrow']) box.setText('Are you sure you want to quit?') box.setWindowTitle('Please confirm!') box.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog) box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) box.setDefaultButton(QMessageBox.No) if box.exec() == QMessageBox.Yes: self.close() QGuiApplication.restoreOverrideCursor() elif e.key() == Qt.Key_Space or e.key() == Qt.Key_Backspace: self.tree.setCurrentItem(self.tree.topLevelItem(0)) self.tree.collapseAll() self.tree.topLevelItem(0).setExpanded(True) elif e.key() == Qt.Key_Down: ni = self.tree.itemBelow(self.tree.currentItem()) if (ni != None): self.tree.setCurrentItem(ni) elif e.key() == Qt.Key_Up: ni = self.tree.itemAbove(self.tree.currentItem()) if (ni != None): self.tree.setCurrentItem(ni) elif e.key() == Qt.Key_Left: ni = self.tree.currentItem().parent() if (ni != None): self.tree.setCurrentItem(ni) elif e.key() == Qt.Key_Right or e.key() == Qt.Key_Return or e.key( ) == Qt.Key_Enter: ni = self.tree.currentItem().child(0) if (ni != None): self.tree.setCurrentItem(ni) else: self.tree.open(self.tree.currentItem(), False) elif e.key() == Qt.Key_Slash: self.tree.hideEmptyFolders(not self.tree.isHidingEmptyFolders) self.instructionsLabel.setText( self.instructionsTemplate.format( fontSize=int(self.fontSize), fontSizeLarge=int(self.fontSizeLarge), fontSizeSmall=int(self.fontSizeSmall), emptyFolderOp=('show' if self.tree.isHidingEmptyFolders else 'hide'))) #elif e.key()==Qt.Key_0 or e.key()==Qt.Key_1 or e.key()==Qt.Key_2 or e.key()==Qt.Key_3 or e.key()==Qt.Key_4 or e.key()==Qt.Key_5 or e.key()==Qt.Key_6 or e.key()==Qt.Key_7 or e.key()==Qt.Key_8 or e.key()==Qt.Key_9 : else: self.tree.clearSelection() self.tree.keyboardSearch(e.text()) sel = self.tree.selectedItems() if len(sel) > 0: self.tree.onClick(sel[0], 0) def onSpecs(self): box = QMessageBox(self) horizontalSpacer = QSpacerItem(1000, 0, QSizePolicy.Minimum, QSizePolicy.Expanding) box.setText(gears.getSpecs()) box.setWindowTitle('System specs') box.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog) box.setStandardButtons(QMessageBox.Ok) box.setDefaultButton(QMessageBox.Ok) layout = box.layout() layout.addItem(horizontalSpacer, layout.rowCount(), 0, 1, layout.columnCount()) box.exec() def onQuit(self): box = QMessageBox(self) #box.setCursor(AppData.cursors['arrow']) QGuiApplication.setOverrideCursor(AppData.cursors['arrow']) box.setText('Are you sure you want to quit?') box.setWindowTitle('Please confirm!') box.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog) box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) box.setDefaultButton(QMessageBox.No) if box.exec() == QMessageBox.Yes: self.close() QGuiApplication.restoreOverrideCursor() 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) def wheelEvent(self, event): if self.app.keyboardModifiers() & Qt.ControlModifier: self.fontSize += event.angleDelta().y() / 120 self.fontSizeLarge += event.angleDelta().y() / 120 self.fontSizeSmall += event.angleDelta().y() / 120 self.setStyleSheet( self.styleTemplate.format(fontSize=int(self.fontSize), fontSizeLarge=int( self.fontSizeLarge))) self.titleLabel.setText( self.titleTemplate.format( fontSize=int(self.fontSize), fontSizeLarge=int(self.fontSizeLarge), fontSizeSmall=int(self.fontSizeSmall))) self.instructionsLabel.setText( self.instructionsTemplate.format( fontSize=int(self.fontSize), fontSizeLarge=int(self.fontSizeLarge), fontSizeSmall=int(self.fontSizeSmall), emptyFolderOp=('show' if self.tree.isHidingEmptyFolders else 'hide'))) self.tree.resizeColumnToContents(0) self.updateGeometry() #def eventFilter(self, obj, event): # #if event.type() in [ QEvent.MouseMove, QEvent.MouseButtonPress, QEvent.MouseButtonRelease, QEvent.MouseButtonDblClick]: # self.app.sendEvent(self.gridWidget, event) # return super().eventFilter(obj, event) def sizeHint(self): return self.app.desktop().screenGeometry().size()
def setLexer(self, lexer): QsciScintilla.setLexer(self, lexer) self._lexer = lexer self.lexerChanged.emit(lexer)
def initialize_editor(self): self.editor = QsciScintilla() # self.editor.cursorPositionChanged.connect(self.e) # self.editor.copyAvailable.connect(self.e) # self.editor.indicatorClicked.connect(self.e) # self.editor.indicatorReleased.connect(self.e) # self.editor.linesChanged.connect(self.e) # self.editor.marginClicked.connect(self.e) # self.editor.modificationAttempted.connect(self.e) # self.editor.modificationChanged.connect(self.e) # self.editor.selectionChanged.connect(self.e) # self.editor.textChanged.connect(self.e) # self.editor.userListActivated.connect(self.e) if self.editor.__class__.__name__ == "LineTextWidget": return # When using PySide without QSciScintilla # define the font to use font = QFont() font.setFamily("Consolas") 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 self.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) self.editor.setTabWidth(4) # Folding visual : we will use boxes self.editor.setFolding(QsciScintilla.BoxedTreeFoldStyle) self.editor.setAutoIndent(True) # 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 self.lexer = QsciLexerPython() self.lexer.setDefaultFont(font) # Set the length of the string before the editor tries to autocomplete # In practise this would be higher than 1 # But its set lower here to make the autocompletion more obvious self.editor.setAutoCompletionThreshold(1) # Tell the editor we are using a QsciAPI for the autocompletion self.editor.setAutoCompletionSource(QsciScintilla.AcsAPIs) self.editor.setLexer(self.lexer) self.editor.setCallTipsStyle(QsciScintilla.CallTipsContext) # self.editor.setCallTipsVisible(0) # Create an API for us to populate with our autocomplete terms self.api = QsciAPIs(self.lexer) # Compile the api for use in the lexer self.api.prepare()
def lexer(self): lexer = QsciScintilla.lexer(self) if lexer is None: lexer = self._lexer return lexer
def setMarkerForegroundColor(self, color, marker): marker = self._markerToId(marker) return QsciScintilla.setMarkerForegroundColor(self, color, marker)
def _findNext(self, query: FindQuery): query.callback(QsciScintilla.findNext(self))
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()}) ''''''
def clearIndicatorRange(self, lineFrom, indexFrom, lineTo, indexTo, indic): indic = self._indicatorToId(indic) return QsciScintilla.clearIndicatorRange(self, lineFrom, indexFrom, lineTo, indexTo, indic)
def markerAdd(self, line, marker): """Add marker with name/id `i` at line `ln`""" marker = self._markerToId(marker) return QsciScintilla.markerAdd(self, line, marker)
def markerDelete(self, line, marker): """Delete marker with name/id `i` from line `ln`""" marker = self._markerToId(marker) return QsciScintilla.markerDelete(self, line, marker)
def setMarkerBackgroundColor(self, color, marker): """Set background color `c` to marker with id/name `i`""" marker = self._markerToId(marker) return QsciScintilla.setMarkerBackgroundColor(self, color, marker)
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_())
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)
#!/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_()
class ScriptTab(QWidget,): autocomplete_lst = [] def __init__(self, parent, name, script="", filemodified=0): QWidget.__init__(self) self.parent = parent self.tabWidget = self.parent.ui.tabWidget self.gridlayout = QGridLayout(self) self._dirty = False self.initialize_editor() self.gridlayout.addWidget(self.editor) self.setAcceptDrops(True) self.filename = name self.filemodified = filemodified if self.is_file(): self.title = os.path.basename(name) # if self.equals_saved(): # self.filemodified = os.path.getmtime(self.filename) else: self.filename = "" self.title = name # Show this file in the self.editor self.editor.setText(script) self.clean_txt = self.saved() self.update_dirty() self.editor.keyPressEvent = self.key_press_event @property def scriptRunner(self): return self.parent.controller.scriptRunner def wheelEvent(self, event): if event.modifiers() == Qt.ControlModifier: if event.delta() > 0: self.editor.zoomIn() else: self.editor.zoomOut() return QWidget.wheelEvent(self, event) def initialize_editor(self): self.editor = QsciScintilla() # self.editor.cursorPositionChanged.connect(self.e) # self.editor.copyAvailable.connect(self.e) # self.editor.indicatorClicked.connect(self.e) # self.editor.indicatorReleased.connect(self.e) # self.editor.linesChanged.connect(self.e) # self.editor.marginClicked.connect(self.e) # self.editor.modificationAttempted.connect(self.e) # self.editor.modificationChanged.connect(self.e) # self.editor.selectionChanged.connect(self.e) # self.editor.textChanged.connect(self.e) # self.editor.userListActivated.connect(self.e) if self.editor.__class__.__name__ == "LineTextWidget": return # When using PySide without QSciScintilla # define the font to use font = QFont() font.setFamily("Consolas") 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 self.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) self.editor.setTabWidth(4) # Folding visual : we will use boxes self.editor.setFolding(QsciScintilla.BoxedTreeFoldStyle) self.editor.setAutoIndent(True) # 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 self.lexer = QsciLexerPython() self.lexer.setDefaultFont(font) # Set the length of the string before the editor tries to autocomplete # In practise this would be higher than 1 # But its set lower here to make the autocompletion more obvious self.editor.setAutoCompletionThreshold(1) # Tell the editor we are using a QsciAPI for the autocompletion self.editor.setAutoCompletionSource(QsciScintilla.AcsAPIs) self.editor.setLexer(self.lexer) self.editor.setCallTipsStyle(QsciScintilla.CallTipsContext) # self.editor.setCallTipsVisible(0) # Create an API for us to populate with our autocomplete terms self.api = QsciAPIs(self.lexer) # Compile the api for use in the lexer self.api.prepare() # def tefocusInEvent(self, event): # self.parent.focusInEvent(event) # return QTextEdit.focusInEvent(self.textEditScript, event) def is_file(self): return os.path.isfile(self.filename) def is_modified(self): if self.is_file(): if self.equals_saved(): self.filemodified = os.path.getmtime(self.filename) return str(os.path.getmtime(self.filename)) != str(self.filemodified) else: return False def saved(self): if self.is_file(): f = open(self.filename) saved = f.read() f.close() return saved.strip() else: return "" def equals_saved(self): curr_lines = self.get_script().strip().splitlines() saved_lines = self.saved().strip().splitlines() if len(curr_lines) != len(saved_lines): return False for cl, sl in zip(curr_lines, saved_lines): if cl.strip() != sl.strip(): return False return True @property def dirty(self): if not self._dirty: self.dirty = self.clean_txt != self.get_script() return self._dirty @dirty.setter def dirty(self, dirty): if dirty is False: self.clean_txt = self.get_script() if self._dirty != dirty: self._dirty = dirty self.filename_changed() def update_dirty(self): return self.dirty def index(self): return self.tabWidget.indexOf(self) def filename_changed(self): index = self.parent.ui.tabWidget.indexOf(self) if self.dirty: self.tabWidget.setTabText(index, "%s*" % self.title) else: self.tabWidget.setTabText(index, self.title) def reload(self): self.set_script(self.parent._load_script(self.filename)) self.filemodified = os.path.getmtime(self.filename) def close(self): while self.dirty is True: # While avoids data loss, in case save operation is aborted if self.filename == "": text = "Save unsaved changes?" else: text = "Save %s?" % self.filename ans = QMessageBox.question(self, 'Save', text, QMessageBox.Yes, QMessageBox.Cancel, QMessageBox.No) if ans == QMessageBox.Cancel: return elif ans == QMessageBox.Yes: self.parent.actionSave(False) elif ans == QMessageBox.No: break self.tabWidget.removeTab(self.index()) def _save(self,): f = open(self.filename, 'w') f.write(self.get_script()) f.close() self.title = os.path.basename(self.filename) self.dirty = False def key_press_event(self, event): self.update_dirty() if self.editor.__class__.__name__ == "LineTextWidget": return self.editor.edit.keyReleaseEvent(event) # When using PySide without QSciScintilla QsciScintilla.keyPressEvent(self.editor, event) linenr, pos_in_line = self.editor.getCursorPosition() line = str(self.editor.text(linenr)[:pos_in_line]) if event.key() == Qt.Key_F1: try: self.parent.show_documentation(getattr(self.scriptRunner, str(self.editor.selectedText()))) except AttributeError: pass if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return: for tip in self.autocomplete_lst: try: if line.endswith(tip[:tip.index('(') ]): self.editor.insert(tip[tip.index('('):]) parent, residual = self.scriptRunner.split_line(line) self.parent.show_documentation(self.scriptRunner.get_function_dict(parent, residual)[residual]) return except ValueError: pass if event.key() < 100 or event.key() in [Qt.Key_Backspace, Qt.Key_Shift]: linenr, pos_in_line = self.editor.getCursorPosition() line = str(self.editor.text(linenr)[:pos_in_line]) lst = self.scriptRunner.get_autocomplete_list(line) if lst is not None: self.api.clear() list(map(self.api.add, lst)) self.api.prepare() if len(lst) > 0: self.autocomplete_lst = lst self.editor.autoCompleteFromAll() shift_event = QKeyEvent(QEvent.KeyPress, Qt.Key_Shift, Qt.NoModifier) QsciScintilla.keyPressEvent(self.editor, shift_event) # show autocomplete list def set_script(self, script): self.editor.setText(script) def get_script(self): return str(self.editor.text()).replace("\r", "").replace(">>> ", "").replace("\t", " ") def dropHandler(self, dataItemList, ctrl, shift, event): pass
def _cancelFind(self): QsciScintilla.cancelFind(self)
def __init__(self, name, transition): super(QDialog, self).__init__() self.transition = transition self.setWindowTitle(name) self.resize(800, 600) self.codeEdit = QsciScintilla() self.codeEdit.setText(self.transition.getCode()) 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.language = 'python' self.pythonButton = QRadioButton('Python') self.pythonButton.setChecked(True) self.pythonButton.clicked.connect(self.pythonClicked) self.cppButton = QRadioButton('C++') self.cppButton.clicked.connect(self.cppClicked) codeLanguageContainer = QWidget() hLayout0 = QHBoxLayout() hLayout0.addWidget(self.pythonButton) hLayout0.addWidget(self.cppButton) codeLanguageContainer.setLayout(hLayout0) self.temporalButton = QRadioButton('Temporal', self) self.temporalButton.toggled.connect(self.temporalToggled) self.conditionalButton = QRadioButton('Conditional', self) self.conditionalButton.toggled.connect(self.conditionalToggled) radioButtonContainer = QGroupBox() radioButtonContainer.setTitle('Transition Type') vLayout = QVBoxLayout() vLayout.addWidget(self.temporalButton) vLayout.addWidget(self.conditionalButton) radioButtonContainer.setLayout(vLayout) self.transitionTypeCode = QTextEdit() self.transitionTypeCode.setFont(fixedWidthFont) self.transitionGroupBox = QGroupBox() self.transitionGroupBox.setTitle('Temporal (number in ms)') h3Layout = QHBoxLayout() h3Layout.addWidget(self.transitionTypeCode) self.transitionGroupBox.setLayout(h3Layout) typeContainer = QWidget() h2Layout = QHBoxLayout() h2Layout.addWidget(radioButtonContainer) h2Layout.addWidget(self.transitionGroupBox) typeContainer.setLayout(h2Layout) verticalLayout = QVBoxLayout() verticalLayout.addWidget(typeContainer) verticalLayout.addWidget(codeLanguageContainer) 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) if self.transition.getType() == TransitionType.CONDITIONAL: self.conditionalButton.setChecked(True) self.conditionalToggled() elif self.transition.getType() == TransitionType.TEMPORAL: self.temporalButton.setChecked(True) self.temporalToggled()