Package: textual-paint
Textual PaintMS Paint in your terminal.This is a TUI (Text User Interface) image editor, inspired by MS Paint, built withTextual.FeaturesOpen and save imagesFancy file dialogsDrag and drop files to openWarnings when overwriting an existing file, or closing with unsaved changesAuto-saves a temporary.ans~backup file alongside the file you're editing, for crash recoveryEdits ANSI art and raster images and more. SeeFile FormatsAll tools from MS Paint: Free-Form Select, Select, Eraser/Color Eraser, Fill With Color, Pick Color, Magnifier, Pencil, Brush, Airbrush, Text, Line, Curve, Rectangle, Polygon, Ellipse, and Rounded RectangleColor paletteEfficient screen updates and undo/redo history, by tracking regions affected by each actionYou should be able to use this over SSHBrush previewsStatus barMenu barKeyboard shortcutsNearly every command from MS Paint is supported, including fun ones like:Flip/RotateStretch/SkewEdit ColorsSet As Wallpaper (Tiled/Centered)Localization into 26 languages: Arabic, Czech, Danish, German, Greek, English, Spanish, Finnish, French, Hebrew, Hungarian, Italian, Japanese, Korean, Dutch, Norwegian, Polish, Portuguese, Brazilian Portuguese, Russian, Slovak, Slovenian, Swedish, Turkish, Chinese, Simplified ChineseDark modeZooming works with text, despite running in the terminal :)UsagePython 3.10 or later is required. SeeCompatibilityfor details on terminals supported.InstallationUsepipxto install globally, without installing dependencies globally:pipinstall--upgradepipx# or in Arch Linux, sudo pacman -S python-pipxpipxinstalltextual-paintAlternatively, you can install usingpip:pipinstalltextual-paintRunningtextual-paintCommand Line Options$ textual-paint --help
usage: textual-paint [options] [filename]

Paint in the terminal.

positional arguments:
  filename              Path to a file to open. File will be created if it
                        doesn't exist.

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --theme {light,dark}  Theme to use, either "light" or "dark"
  --language {ar,cs,da,de,el,en,es,fi,fr,he,hu,it,ja,ko,nl,no,pl,pt,pt-br,ru,sk,sl,sv,tr,zh,zh-simplified}
                        Language to use
  --ascii-only-icons    Use only ASCII characters for tool icons, no emoji or
                        other Unicode symbols
  --ascii-only          Use only ASCII characters for the entire UI, for use in
                        older terminals. Implies --ascii-only-icons
  --backup-folder FOLDER
                        Folder to save backups to. By default a backup is saved
                        alongside the edited file.

development options:
  --inspect-layout      Enables DOM inspector (F12) and middle click highlight
  --clear-screen        Clear the screen before starting, to avoid seeing
                        outdated errors
  --restart-on-changes  Restart the app when the source code is changedKeyboard ShortcutsCtrl+D: Toggle Dark ModeCtrl+Q: QuitCtrl+Shift+S: Save AsIF SHIFT IS DETECTED— ⚠️ it might trigger Save instead, and overwrite the open file!Ctrl+Shift+Z: RedoIF SHIFT IS DETECTED— ⚠️ it might trigger Undo instead.The rest match MS Paint's keyboard shortcuts:Ctrl+S: SaveCtrl+O: OpenCtrl+N: NewCtrl+T: Toggle Tools BoxCtrl+W: Toggle Colors BoxCtrl+Z: UndoCtrl+Y: RedoF4: RedoCtrl+A: Select AllDelete: Clear SelectionCtrl+C: CopyCtrl+V: PasteCtrl+X: CutCtrl+E: Image AttributesCtrl+PageUp: Large SizeCtrl+PageDown: Normal SizeFile FormatsMany file formats are supported, including ANSI art, raster images, SVG and HTML.To choose a file format when saving, type its file extension. For example, to save a PNG, add.pngto the end of the filename. The default is.ans.FormatNotesANSI(.ans)Note that while it handles many more ANSI control codes when loading than those that it uses to save files, you may have limited success loading other ANSI files that you find on the web, or create with other tools. ANSI files can vary a lot and even encode animations!mIRC codes(.irc, .mirc)invented file extensions, and not to be confused with .mrc mIRC script filesPlain Text(.txt)SVG(.svg)can open SVGs saved by Textual Paint, which embed ANSI data; can also open some other SVGs that consist of a grid of rectangles and text elements. For fun, as a challenge, I made it quite flexible; it can handle uneven grids of unsorted rectangles. But that's only used as a fallback, because it's not perfect.HTML(.htm, html)write-only (opening not supported)PNG(.png)opens first frame of an APNG fileBitmap(.bmp)GIF(.gif)opens first frameTIFF(.tiff)opens first frameWebP(.webp)opens first frameJPEG(.jpg, .jpeg)saving disabled because it's lossy (it would destroy your pixel art)Windows Icon(.ico)opens largest size in the fileMac OS Icon(.icns)opens largest size in the file; saving disabled because it requires specific sizesWindows Cursor(.cur)opens largest size in the file; saving not supported by Pillow (and it would need a defined hot spot)SeePillow's documentationfor more supported formats.Note that metadata is not preserved when opening and saving image files. This is however common for many image editors.TipsYou can draw with a character by clicking the selected color display area in the palette and then typing the character,
or by double clicking the same area to pick a character from a list.You can set the text color by right clicking or holdingCtrlwhile clicking a color in the palette.
Also, if you double right click or holdCtrlwhile double clicking on a color to open the Edit Colors dialog,
if will edit the text color when you click OK.You can swap the foreground and background colors by right clicking or holdingCtrlwhile clicking the current colors area.
This is a great convenience, especially when using the Color Eraser tool, or when using custom colors that may be hard to distinguish.You can display a saved ANSI file in the terminal withcat:catsamples/ship.ansTo browse the sample art, run:python-msrc.textual_paint.galleryTo preview ANSI art files in file managers like Nautilus, Thunar, Nemo, or Caja, you can install theansi-art-thumbnailerprogram I made to go along with this project.Known IssuesUndo/Redo doesn't work inside the Text tool's textbox.Ctrl+Zwill delete the textbox. (Also note that the Text tool works differently from MS Paint; it will overwrite characters and the cursor can move freely, which makes it better for ASCII art, but worse for prose.)The Text tool's cursor doesn't blink.The selection box border appears inside instead of outside (and lacks dashes). For the text box, I hid the border because it was too visually confusing, but it should also have an outer border.Pressing both mouse buttons stops the current tool, but doesn't undo the current action. Also Pick Color can't be cancelled (withEscor by pressing both mouse buttons), since it samples the color continuously.Due to limitations of the terminal, shortcuts usingShiftorAltmight not work. Menus are not keyboard navigable, because I can't detectAlt+F, etc.The Zoom submenu flickers as it opens, and may not always open in the right place. (Fixed?)The canvas flickers when zooming in with the Magnifier tool.Some languages don't display correctly.Large files can make the program very slow, as can magnifying the canvas. There is a 500 KB limit when opening files to prevent it from freezing.The status bar description can be left blank when selecting a menu item. (I think theLeaveevent can come after closing, once the mouse moves.)Menu items like Copy/Cut/Paste are not grayed out when inapplicable. Only unimplemented items are grayed out.ANSI files (.ans) are treated as UTF-8 when saving and loading, rather than CP437 or Windows-1252 or any other encodings. Unicode is nice and modern terminals support it, but it's not the standard for ANSI files. There isn't really a standard for ANSI files.ANSI files are loaded with a white background. This may make sense as a default for text files, but ANSI files either draw a background or assume a black background, being designed for terminals.Hitting Enter in View Bitmap mode may trigger a menu item while exiting the mode. Menu items ought to be disabled when hidden, and View Bitmap should also prevent the key event from taking other actions if possible.Airbrush is continuous in space instead of time. It should keep spraying while the mouse stays still.Error messages may not show up when opening a file fails. I'm not sure how to reproduce this, so if you run into this, do let me know.Edit Colors dialogFocus ring shows even while grid is not focusedCan show two cells as selected, instead of one across both gridsCustom colors order X/Y is different from MS PaintPressing enter in color grid should select color and closeSelection ring is hard to see in dark modeFocus ring is invisible on a black color cellWhen dragging on the color field or luminosity slider, the cursor can be seen to jump back to earlier places where the mouse was, before settling at the current position. (This may only be visible when the program is running slowly, such while debugging. I haven't observed this on the canvas, so maybe it has something to do with the dialog being on a separate layer.)When opening the Edit Colors dialog, it may immediately close, if the mouse lines up with the "OK" or "Cancel" buttons. (This doesn't seem to currently happen, but I haven't knowingly fixed it. A git bisect turned up a bogus commit, possibly due to reproducing the behavior being unreliable. It also seems like it might depend on the specific layout of the dialog, which changed during development, and maybe even the terminal size.)CompatibilityPython 3.10 or later is required.LinuxTested on Ubuntu 22, with GNOME Terminal, Kitty, XTerm, and VS Code's integrated terminal.GNOME Terminal works best, with crisp triangles used for icons in dialogs, emoji support, and true color support.Kitty works fine, supporting true color and emoji.XTerm supports true color, but not emoji. Run withCOLORTERM=truecolor textual-paint --ascii-onlyfor XTerm compatibility.macOSTested on OSX 10.14 (Mojave), with iTerm2, and VS Code's integrated terminal.In VS Code, Free-Form Select shows as tofu (a missing character symbol).The default Terminal has missing characters, causing misalignment of everything to the right of them, plus borders are not rendered nicely, giving it a sort offrayed fabriclook, and it's limited to 256 colors.WindowsTextual Paint works with the newWindows Terminal.Pasting in Windows TerminalCtrl+Vdoes not workto paste by default, butEdit > Pastedoes work.
You can unbindCtrl+Vto fix this:Open Windows Terminal's Settings (Ctrl+,)Click "Open JSON file"Disable the paste binding by adding//to the beginning of the lines:// {//     "command": "paste",//     "keys": "ctrl+v"// },Save the file, and the behavior should update immediately.Alternatively, you can use the Actions tab of the Settings UI to remove the binding forCtrl+V.If you're wondering whyremovingthe Paste binding fixes it, it's because Textual Paint needs to receive the literalCtrl+Vkey presses in order to trigger its own Paste command.Powershell ProblemsRunning in Powershell, you may run into a bug where the powershell prompt becomes active at the same time as the TUI.
Moving the mouse will redraw parts of the TUI, and it becomes hard to click on things, but still possible.
Commands can be entered, and the output will be interwoven with the TUI, including if you run a second instance of the program, in which case the two instances will vie for the screen.
If this happens, I would recommend first messing around with it, since it's a fun glitch, then opening a new tab in Windows Terminal with theCommand Prompt profile, available in the new tab dropdown menu.Windows ConsoleTextual Paint willnotwork properly with the old Windows console (conhost.exe), which lacks emoji/Unicode support and true color support.
This program is commonly thought of as the "Command Prompt", but the Command Prompt (cmd.exe) is actually ashell(likebash) that can run in either the old console or the new Windows Terminal, which are bothterminal emulators.You can run with--ascii-onlyto limit the characters used in the UI to ASCII, but colors will still be limited and similar colors will appear confusingly identical.VS CodeNote that VS Code's integrated terminal tries to fix the contrast of text, including in the canvas, which is entirely inappropriate for an ANSI art editor, as it obscures the colors, and can indeedharmthe contrast of the resulting document, by tricking you into thinking there's more contrast than there actually is.To disable this, you can add this to your settings.json:"terminal.integrated.minimumContrastRatio":1If this doesn't work, try increasing it to 1.1.DevelopmentFirst, create a virtual environment, and activate it:python-mvenv.venv# The activate script is in different places on different systems:# Linux/macOS:source.venv/bin/activate# Windows:.venv\Scripts\activateInstall Textual and other dependencies:pipinstall-rrequirements.txtRun the app via Textual's CLI for live-reloading CSS support, and enable other development features:textualrun--dev"src.textual_paint.paint --clear-screen --inspect-layout --restart-on-changes"Or run more basically:python-msrc.textual_paint.paintOr install the CLI globally*:pipinstall--editable.Then run:textual-paint*If you use a virtual environment, it will only install within that environment.--clear-screenis useful for development, because it's sometimes jarring or perplexing to see error messages that have actually been fixed, when exiting the program.--inspect-layoutenables a DOM inspector accessible with F12, which I built. It also lets you apply a rainbow highlight and labels to all ancestors under the mouse with middle click, but this is mostly obsolete/redundant with the DOM inspector now. The labels affect the layout, so you can also hold Ctrl to only colorize, and you can remember how the colors correspond to the labels, to build a mental model of the layout.--restart-on-changesautomatically restarts the program when any Python files change. This works by the program restarting itself directly. (Programs likemoddornodemonthat run your program in a subprocess don't work well with a TUI's escape sequences.)There are also launch tasks configured for VS Code, so you can run the program from the Run and Debug panel.
Note that it runs slower in VS Code's debugger.To see logs, runtextual consoleand then run the program viatextual run --dev.
This also makes it run slower.Often it's useful to exclude events withtextual console -x EVENT.TroubleshootingUnable to import 'app' from module 'src.textual_paint.paint'Make sure to activate the virtual environment, if you're using one.Make sure to run the program from the root directory of the repository.ModuleNotFoundError: No module named 'src'Make sure to run the program from the root directory of the repository.Quality Assurance# Spell checking# I use the VS Code extension "Code Spell Checker", and its associated CLI:cspell-clilint.# Type checking# I use the "Python" and "Pylance" VS Code extensions, and the Pyright CLI:pyright# I'm targeting zero errors at this version of Pyright:PYRIGHT_PYTHON_FORCE_VERSION=1.1.345pyright# I also tried mypy and fixed some errors it reported, but I'm not targeting zero errors with mypy.mypysrc--no-namespace-packages--check-untyped-defs# Visual Regression Testing (and a few other tests)# I use pytest-textual-snapshot, which is a pytest plugin for comparing SVG screenshots of Textual apps over time.pytest# To accept differences, update the baseline with:pytest--snapshot-update# I also made a test recorder, which can generate test code, which is great for creating tests that interact with the canvas.# Run with:pythontests/pilot_recorder.py# Then interact with the app, and press Ctrl+C to stop recording.# You can also hit Ctrl+R to replay what you have,# or Ctrl+Z to remove the last step and replay the rest.PublishingRun QA steps aboveUpdate version numbers insetup.cfgandsrc/textual_paint/__init__.pyto a pre-release version (e.g.0.3.0-pre.1)Add version header toCHANGELOG.mdbelow "Unreleased", and update version links at bottomCommit (e.g.git commit -m "Prepare v0.3.0")Build package:python -m build --sdist --wheelUpload to TestPyPI: (updating version numbers)python -m twine upload --repository testpypi dist/textual_paint-0.3.0rc1-py3-none-any.whl dist/textual_paint-0.3.0rc1.tar.gzTest installing from TestPyPI with: (outside the venv, updating the version number)pipx uninstall textual-paint; pipx install textual-paint==0.3.0rc1 --pip-args "--index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple textual-paint"If all is good, update version numbers to remove-pre.NsuffixesAmend commit (git commit --amend --no-edit)Rebuild:python -m build --sdist --wheelUpload to PyPI:python -m twine upload dist/textual_paint-0.3.0-py3-none-any.whl dist/textual_paint-0.3.0.tar.gzPushmainbranch (git push origin main)Tag and push tag (e.g.git tag v0.3.0 && git push origin v0.3.0)LicenseMITNewsFor a history of changes to the project, see thechangelog.Unicode Symbols and Emojis for Paint ToolsThe first thing I did in this project was to collect possible characters to represent all the tool icons in MS Paint, to gauge how good of a recreation it would be possible to achieve, starting from looks.
As it turns out, I didn't run into any significant roadblocks, so I ended up recreating MS Paint.Again.These are the symbols I've found so far:Free-Form Select: ✂️📐🆓🕸✨☆⚝⛤⛥⛦⛧⚛🫥🇫/🇸◌⁛⁘ ⢼⠮ 📿➰➿𓍼യ🪢𓍯 𔗫 𓍲 𓍱 ౿ Ꮼ ᏈSelect: ✂️⬚▧🔲 ⣏⣹ ⛶Eraser/Color Eraser: 🧼🧽🧹🚫👋🗑️▰▱Fill With Color: 🌊💦💧🩸🌈🎉🎊🪣🫗🚰⛽🍯 ꗃ﹆ ⬙﹅ 🪣﹅Pick Color: 🎨🌈💉💅💧🩸🎈📌📍🪛🪠🥍🩼🌡💄🎯𖡡⤤𝀃🝯⊸⚲𓋼🗡𓍊🍶🧪🍼🌂👁️‍🗨️🧿🍷⤵❣⚗ ⤆Ϸ ⟽þ ⇐ c⟾ /̥͚̥̥͚͚̊̊Magnifier: 🔍🔎👀🔬🔭🧐🕵️‍♂️🕵️‍♀️Pencil: ✏️✎✍️🖎🖊️🖋️✒️🖆📝🖍️🪶🪈🥖🥕▪Brush: 🖌👨‍🎨🧑‍🎨💅🧹🪮🪥🪒🪠ⵄ⑃ሐ⋔⋲ ▭⋹ 𝈸⋹ ⊏⋹ ⸦⋹ ⊂⋹ ▬▤Airbrush: ⛫💨дᖜ💨╔💨🧴🥤🧃🧯🧨🍾🥫💈🫠🌬️🗯☄💭༄༺☁️🌪️🌫🌀🚿 ⪧𖤘 ᗒᗣ дᖜᗕText: 📝📄📃📜AＡ🅰️🆎🔤🔠𝐴Line: 📏📉📈＼⟍𝈏╲⧹\⧵∖Curve: ↪️🪝🌙〰️◡◠~∼≈∽∿〜〰﹋﹏≈≋～⁓Rectangle: ▭▬▮▯➖🟥🟧🟨🟩🟦🟪🟫⬛⬜🔲🔳⏹️◼️◻️◾◽▪️▫️Polygon: ▙𝗟𝙇﹄』𓊋⬣⬟🔶🔷🔸🔹🔺🔻△▲☖⛉♦️🛑📐🪁✴️Ellipse: ⬭⭕🔴🟠🟡🟢🔵🟣🟤⚫⚪🔘🫧🕳️🥚💫💊🛞Rounded Rectangle: ▢⬜⬛𓋰⌨️⏺️💳📺🧫The default symbols used may not be the best on your particular system, so I may add some kind of configuration for this in the future.CursorA crosshair cursor could use one of+✜✛⊹✚╋╬⁘⁛𖥔⌖⯐, but it might be better to show the pixel under the cursor, i.e. character cell, surrounded by dashes, like this:╻
╺█╸
 ╹See AlsoJavE, an advanced Java-based ASCII art editorPlayscii, a beautiful ASCII/ANSI art editor. This is also written in Python and MIT licensed, so I might take some code from it, for converting images to ANSI, for example. Who knows, maybe I could even try to support its file format.cmdpxl, a pixel art editor for the terminal using the keyboardpypixelart, a pixel art editor using vim-like keybindings, inspired by cmdpxl but not terminal-based