Enhanced Flet CodeEditor with file open/save/save-as/close/search and replace capabilities
Project description
fce-enhanced
An enhanced Flet CodeEditor control with file I/O, search/replace, syntax highlighting, and theme selection.
Built on top of flet-code-editor, adding a full-featured editing experience you can drop into any Flet app or run standalone. This project was created to explore and showcase what's possible with Flet — building a desktop-quality code editor entirely in Python.
Install
pip install fce-enhanced
Or with uv:
uv add fce-enhanced
Development setup
git clone https://github.com/oktl/flet-fce-enhanced.git
cd flet-fce-enhanced
uv sync
source .venv/bin/activate
pre-commit install # optional, for development
Usage
Run as a standalone app
uvx fce-enhanced
During development:
flet run src/fce_enhanced/editor.py
Embed in your own Flet app
EnhancedCodeEditor is a standard ft.Column subclass — add it to any Flet page or layout just like any other control.
Minimal example
import flet as ft
from fce_enhanced import EnhancedCodeEditor
def main(page: ft.Page):
page.title = "My Editor"
editor = EnhancedCodeEditor(expand=True)
page.add(editor)
ft.run(main)
With configuration
import flet as ft
import flet_code_editor as fce
from fce_enhanced import EnhancedCodeEditor
def main(page: ft.Page):
page.title = "My Editor"
def on_title_change(display_path, name, is_dirty):
page.title = f"{name}{'*' if is_dirty else ''} — My Editor"
page.update()
editor = EnhancedCodeEditor(
language=fce.CodeLanguage.JAVASCRIPT,
value="console.log('hello');",
code_theme=fce.CodeTheme.MONOKAI,
on_title_change=on_title_change,
ruff_on_save=False, # disable ruff (only applies to Python files)
expand=True,
)
page.add(editor)
ft.run(main)
Constructor parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
language |
CodeLanguage |
PLAINTEXT |
Initial syntax highlighting language |
value |
str |
"# New file\n" |
Initial editor content |
show_toolbar |
bool |
True |
Show the file I/O toolbar |
show_status_bar |
bool |
True |
Show the line/column status bar |
show_gutter |
bool |
True |
Show the line-number gutter |
register_keyboard_shortcuts |
bool |
True |
Register global keyboard shortcuts |
autocomplete |
bool |
True |
Enable autocomplete |
autocomplete_words |
list[str] |
None |
Custom autocomplete suggestions |
code_theme |
CodeTheme |
ATOM_ONE_DARK |
Syntax highlighting theme |
text_style |
TextStyle |
None |
Text style for editor content |
gutter_style |
GutterStyle |
None |
Style for the line number gutter |
on_title_change |
callable |
None |
Callback (display_path, name, is_dirty) — fires on file open/close, save, and dirty-state changes. display_path is the home-relative path (e.g. ~/projects/foo.py) or "untitled". |
ruff_on_save |
bool |
True |
Auto-format Python files with ruff on save |
Any additional keyword arguments are passed through to ft.Column.
Useful properties
editor.value # current editor content (str)
editor.current_path # path of open file, or None
editor.dirty # True if there are unsaved changes
editor.language # current CodeLanguage
editor.code_editor # the underlying fce.CodeEditor control
editor.search_bar # the SearchReplaceBar control
Other public exports
The package also exports these utilities from fce_enhanced:
| Export | Description |
|---|---|
SearchReplaceBar |
Reusable search/replace control |
open_file() / save_file() |
Async platform-aware file dialogs |
language_for_path() |
Detect CodeLanguage from a file path |
EXTENSION_TO_LANGUAGE |
Dict mapping file extensions to CodeLanguage |
THEMES / DEFAULT_THEME / theme_display_name() |
Theme utilities |
main() / run() |
Entry points for standalone mode |
Features
- File operations — Open, Save, Save As, Close, and Revert to Saved with unsaved-changes confirmation
- Native file dialogs — AppleScript dialogs on macOS (with extension filtering), Flet's built-in FilePicker on other platforms
- Search & Replace — Find toolbar with match counting, case sensitivity toggle, whole word matching, prev/next navigation (Enter navigates to next match), Replace and Replace All
- Command Palette — Searchable list of all available commands; type to filter (Cmd+Shift+P / Ctrl+Shift+P)
- Theme Selector — 80+ built-in syntax highlighting themes via a searchable dialog (type to filter)
- Go to Line — Jump to a specific line number (Cmd+G / Ctrl+G)
- Read-Only Mode — Toggle editing lock (Cmd+L / Ctrl+L)
- Font Size Controls — Increase/decrease font size (Cmd+= / Cmd+-)
- Language Selector — Choose syntax highlighting language from a searchable dialog (type to filter); auto-detected on file open, and Save As defaults to the matching file extension
- Language Detection — Automatic syntax highlighting for 40+ file extensions
- Dirty-File Tracking — Visual indicator for unsaved changes
- Diff Pane — Toggleable unified diff view showing changes since last save, with green/red syntax coloring (Cmd+D / Ctrl+D)
- Gutter Toggle — Show or hide the line-number gutter (Shift+Cmd+G / Ctrl+Shift+G)
- Ruff on Save — Auto-runs
ruff check --fixandruff formaton.pyfiles; silently skips if ruff is not installed (no error). Remaining lint warnings are shown in a snackbar, and the editor auto-reloads the formatted content. Toggleable from the toolbar - Status Bar — Line, column, language, and selection info
Keyboard shortcuts
| Action | macOS | Windows / Linux |
|---|---|---|
| Open File | ⌘O | Ctrl+O |
| Save | ⌘S | Ctrl+S |
| Save As | ⇧⌘S | Ctrl+Shift+S |
| Close File | ⌘W | Ctrl+W |
| Revert to Saved | ⇧⌘R | Ctrl+Shift+R |
| Find | ⌘F | Ctrl+F |
| Find and Replace | ⌥⌘F | Ctrl+H |
| Toggle Diff | ⌘D | Ctrl+D |
| Toggle Gutter | ⇧⌘G | Ctrl+Shift+G |
| Go to Line | ⌘G | Ctrl+G |
| Toggle Read-Only | ⌘L | Ctrl+L |
| Increase Font Size | ⌘+ | Ctrl++ |
| Decrease Font Size | ⌘- | Ctrl+- |
| Command Palette | ⇧⌘P | Ctrl+Shift+P |
| Help | F1 | F1 |
| Close Search Bar | Esc | Esc |
Contributing
Contributions are welcome! See CONTRIBUTING.md for guidelines.
License
MIT
Development
Code style is enforced with ruff via pre-commit hooks:
pre-commit run --all-files
Run tests:
pytest
Built With
- Flet — Build multi-platform apps in Python powered by Flutter
- flet-code-editor — Code editor control for Flet with syntax highlighting
- ruff — Fast Python linter and formatter
Project details
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 fce_enhanced-0.1.6.tar.gz.
File metadata
- Download URL: fce_enhanced-0.1.6.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35f7b9e02bd1fce05c5298c1a95e1a497e24f70e61a1233043397677218a4120
|
|
| MD5 |
e35f7a6c6150f34c2b3044e74396115e
|
|
| BLAKE2b-256 |
2b9d5b02a271cb671fca8df10dc23b81c7496f1d9b803a61e9d3b476177df5d6
|
Provenance
The following attestation bundles were made for fce_enhanced-0.1.6.tar.gz:
Publisher:
publish.yml on oktl/flet-fce-enhanced
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fce_enhanced-0.1.6.tar.gz -
Subject digest:
35f7b9e02bd1fce05c5298c1a95e1a497e24f70e61a1233043397677218a4120 - Sigstore transparency entry: 1117475425
- Sigstore integration time:
-
Permalink:
oktl/flet-fce-enhanced@7281f5f11bcd5972ed3a1a66a7cb1ab535a557ff -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/oktl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7281f5f11bcd5972ed3a1a66a7cb1ab535a557ff -
Trigger Event:
release
-
Statement type:
File details
Details for the file fce_enhanced-0.1.6-py3-none-any.whl.
File metadata
- Download URL: fce_enhanced-0.1.6-py3-none-any.whl
- Upload date:
- Size: 27.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f9cc64a090d3d9e61869e432443803325bf3e1cfcf620fa4f6f3096a9163c54
|
|
| MD5 |
edeb630561358602af14c1d2fbd82d78
|
|
| BLAKE2b-256 |
572c7a7e3985e537de0643da8357dcafbd63ce534c30e3e89b5010fe463ba3fe
|
Provenance
The following attestation bundles were made for fce_enhanced-0.1.6-py3-none-any.whl:
Publisher:
publish.yml on oktl/flet-fce-enhanced
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fce_enhanced-0.1.6-py3-none-any.whl -
Subject digest:
5f9cc64a090d3d9e61869e432443803325bf3e1cfcf620fa4f6f3096a9163c54 - Sigstore transparency entry: 1117475452
- Sigstore integration time:
-
Permalink:
oktl/flet-fce-enhanced@7281f5f11bcd5972ed3a1a66a7cb1ab535a557ff -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/oktl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7281f5f11bcd5972ed3a1a66a7cb1ab535a557ff -
Trigger Event:
release
-
Statement type: