Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leixingyu/codeeditor
Text editor with line counter and syntax highlighting
https://github.com/leixingyu/codeeditor
code-editor qt syntax-highlighting
Last synced: about 2 months ago
JSON representation
Text editor with line counter and syntax highlighting
- Host: GitHub
- URL: https://github.com/leixingyu/codeeditor
- Owner: leixingyu
- License: mit
- Created: 2022-01-08T15:52:34.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-21T05:58:17.000Z (over 1 year ago)
- Last Synced: 2023-10-21T06:30:11.042Z (over 1 year ago)
- Topics: code-editor, qt, syntax-highlighting
- Language: Python
- Homepage:
- Size: 15.6 KB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Qt Code Editor
A PyQt5/PySide2 version of code editor with line counter and syntax highlighting
## About The Project
A central repo to store useful stuff related to creating a code editor based on PyQt.
It currently consists of the main code editor subclassing from `QPlainTextEdit` with
a side widget for line counter. It currently supports syntax highlighting for
`.json` and `.py` files, they are `QSyntaxHighlighter` class which can be found
in the **highlighter** folder.## Getting Started
### Prerequisites
- [Qt](https://github.com/mottosso/Qt.py): a module that supports different
python qt bindingsor alternatively, change the code below to whatever qt binding you have on your machine.
```python
from Qt import QtWidgets, QtCore, QtGui
from Qt import _loadUi
```### Launch
1. Unzip the **qt-code-editor** package and run `main.py` directly
2. Or include the following snippet to your ui code to create a
code editor with syntax highlighting.
```python
import codeEditor
from highlighter.pyHighlight import PythonHighlightereditor = codeEditor.CodeEditor()
highlighter = PythonHighlighter(editor.document())
```**Note:**
if you are using highlighter in a UI class, you'll need to keep an instance of the highlighter object
like so:```python
self.__highlighter = PythonHighlighter(editor.document())
```### Reference
[Qt Documentation - Code Editor Example](https://doc.qt.io/qt-5/qtwidgets-widgets-codeeditor-example.html)
[Qt for Python 6.2.2 - Code Editor Example](https://doc.qt.io/qtforpython/examples/example_widgets__codeeditor.html)
[Python.org - Python syntax highlighting](https://wiki.python.org/moin/PyQt/Python%20syntax%20highlighting)