A Python editor with syntax highlighting, folding, line numbers, and bracket tracking
Project description
tkeditor
tkeditor is a modern, extensible Tkinter-based code editor framework written in pure Python.
It is designed for building IDE-like applications with syntax highlighting, folding, line numbers, and deep customization.
Unlike basic Tkinter text widgets, tkeditor focuses on performance, flexibility, and developer control.
Features
- Custom lexer system (BaseLexer API)
- Language-agnostic syntax highlighting
- Fully customizable token styles
- Canvas-based line numbers
- Current line highlighting
- Code folding with symbols
- Bracket tracking
- Indentation guides
- Custom scrollbars
- Exposed Frame, Text, and Canvas configuration
- Full .pyi type-hint support for IDE autocomplete
Installation
Using pip
pip install tkeditor
Using uv
uv add tkeditor
Quick Example
import tkinter as tk
from tkeditor import Editor
root = tk.Tk()
root.title("tkeditor demo")
editor = Editor(
root,
linenumber=True,
folder_code=True,
wrap="none",
font=("Consolas", 12),
)
editor.pack(fill="both", expand=True)
root.mainloop()
Syntax highlighting
import tkinter as tk
from tkeditor import Editor
from tkeditor.lexers import PythonLexer,Highlighter
root = tk.Tk()
root.geometry("800x500")
root.title("tkeditor")
editor = Editor(
root,
linenumber=True,
folder_code=True,
wrap="none",
font=("Consolas", 12),
)
editor.pack(expand=True, fill="both")
lexer = PythonLexer()
# set custom syntax colors
# method 1
# lexer.set_styles(
# keyword={"foreground":"tomato"},
# builtin={"foreground":"steelblue"}
# )
# method 2
# lexer.set_styles({
# "keyword":{"foreground":"tomato"},
# "builtin":{"foreground":"steelblue"}
# }
# )
# Note you can also use both methods at same time
highlight = Highlighter(editor.get_text_widget(), lexer)
root.mainloop()
Project Links
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tkeditor-0.1.1.tar.gz.
File metadata
- Download URL: tkeditor-0.1.1.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e68546056e6b28934b03f03b08379af0db18f360e99129d518b174482f8b870
|
|
| MD5 |
925d0132cff7787e0e3b1023b4e8fae1
|
|
| BLAKE2b-256 |
0f1254660f948bd82896acc99e7f1dd4cffd5796db8c5495e36bab57fea76933
|
File details
Details for the file tkeditor-0.1.1-py3-none-any.whl.
File metadata
- Download URL: tkeditor-0.1.1-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e5d840582a5a454c8172db16dfb180b80061c8f1686cd595378f7905b072c8b
|
|
| MD5 |
3912a756355dbae0f57b618e85c40aee
|
|
| BLAKE2b-256 |
522b0bab82dc6c10106deb6eb2ac21662c9b94052a6d60ecacad4d6a5c6333f0
|