CTkCodeBox
Advanced Code Viewer for customtkinter, with line numbers and code highlighting.
Install / Use
/learn @Akascape/CTkCodeBoxREADME
CTkCodeBox
A code editor widget for customtkinter.
Features
- Multiple language support
- Code syntax highlighting
- Multiple Themes
- Right-click copy-paste menu
- Line numbers on left side
- Fully customizable
- Easy to Use
Installation
<img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/Akascape/CTkCodeBox?&color=white&label=Download%20Source%20Code&logo=Python&logoColor=yellow&style=for-the-badge" width="400">
Download the source code, paste the CTkCodeBox folder in the directory where your program is present.
<br> Requirements: Pygments and TkLineNums
Simple Usage
import customtkinter
from CTkCodeBox import *
root = customtkinter.CTk()
codebox = CTkCodeBox(root, language="python")
codebox.pack(padx=10, pady=10, expand=True,fill="both")
root.mainloop()
Arguments
| Parameter | Description | |-----------| ------------| | width | change the default width of the widget | | height | change the default height of the widget | | fg_color | change the fg_color of the widget| | language | set the language lexer for the codebox | | theme | change the overall color theme for the code syntax | | line_numbering | boolean, enable or disable the line numbering | | numbering_color | change text color of the line numbering | | menu | boolean, enable or disable the right click popup menu | | menu_fg_color | color of the menu (optional) | | menu_text_color | text color of the menu buttons (optional) | | menu_hover_color | hover color of the menu buttons (optional) | | wrap | enable or disabled word wrapping in the textbox | | select_color | change the selection color of the codebox | | cursor_color | change the cursor color I (blinking) | | undo | boolean, enable or disable the undo text feature | | *Other Parameters | All other parameters of ctktextbox can be passed in ctkcodebox |
Methods
- .insert(index, code): insert code in the box
- .configure(kwargs): change parameters of the codebox
- .cget(parameter): get the parameter name from the codebox
- .update_code(): update the code syntax colors
- .clear_code(): delete all the code from the box <br>
More lexers available here: https://pygments.org/docs/lexers/
Color Themes
abap, arduino, autumn, borland, colorful, default, dracula, emacs, friendly_grayscale, friendly, fruity, github-dark, gruvbox-dark, gruvbox-light, igor, inkpot, lightbulb, lilypond, lovelace, manni, material, monokai, murphy, native, nord-darker, nord, one-dark, paraiso-dark, paraiso-light, pastie, perldoc, rainbow_dash, rrt, sas, solarized-dark, solarized-light, staroffice, stata-dark, stata-light, tango, trac, vim, vs, xcode, zenburn
More style examples given here: https://pygments.org/styles/
Follow me for more stuff like this: Akascape
That's all, hope this project can help!
Related Skills
node-connect
338.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.6kCommit, push, and open a PR
