| 1 | # Hey there! |
| 2 | |
| 3 | Welcome to the **PyTermGUI** documentation! |
| 4 | |
| 5 | For a general overview of the framework, follow the navigation at the bottom. For a set of working examples, check out the [walkthroughs](/walkthroughs) section. For a complete look at the API, see our [reference](/reference)! |
| 6 | |
| 7 |  |
| 8 | |
| 9 | ## So what is a Terminal User Interface (or TUI) anyways? |
| 10 | |
| 11 | A Terminal User Interface is, in general terms, a GUI in your terminal. Due to the terminal's attributes & limitations it can _only_ use plain text to display content, and has to arrange itself on the terminal's character grid. |
| 12 | |
| 13 | In effect, this means terminal applications are: |
| 14 | |
| 15 | - More constrained, which can often lead to more interesting solutions around known problems |
| 16 | - More standardized (though not enough) |
| 17 | - _Much_ faster to execute |
| 18 | - _Way cooler lookin'_ |
| 19 | |
| 20 | ## If all that is true, why are TUIs so rare? |
| 21 | |
| 22 | Historically, you had 2 options when writing a TUI: |
| 23 | |
| 24 | - Create your own framework with its own rendering pipeline |
| 25 | - Use [curses](https://en.wikipedia.org/wiki/Curses_(programming_library)) or [ncurses](https://en.wikipedia.org/wiki/Ncurses) |
| 26 | |
| 27 | Neither of these are simple to do; drawing in the terminal requires knowledge of a bunch of scattered standards and precedents, which, for the most part, are only available through _archaic_ documentation. |
| 28 | |
| 29 | Things _have_ gotten a lot better in recent years. Projects like [Jexer](https://jexer.sourceforge.io/) and [notcurses](https://github.com/dankamongmen/notcurses) have shown how capable terminals are, and projects like [bubbletea](https://github.com/charmbracelet/bubbletea) and [tui-rs](https://github.com/fdehau/tui-rs) have made simplified and modernized TUI creation. |
| 30 | |
| 31 | ## How do we help the situation? |
| 32 | |
| 33 | PTG provides abstractions for the low-level interactions with the terminal, and a modular widget system that is built ontop. |
| 34 | |
| 35 | Our goals are the following: |
| 36 | |
| 37 | - Versatility |
| 38 | - Expressive, readable but compact code |
| 39 | - No pointless abstractions |
| 40 | - Minimal dependencies |
| 41 | |
| 42 | Because of the way the framework is built, you can implement the input-key-mouse-draw loop used internally by [WindowManager](/reference/pytermgui/window_manager.manager#pytermgui.window_manager.WindowManager) in {insert linecount} lines! |
| 43 | |
| 44 | Widget layouts are explicit from the syntax of their creation. Widgets are rendered line-by-line, using the plain strings they return. There is built-in support for [keyboard](/widgets/custom#keyboard-input) & [mouse](/widgets/custom#mouse-input) inputs on all widgets, as well as the underlying low-level API that is used to make it all work. |
| 45 | |
| 46 | This means that you, the user, can create TUI applications with workflows that rival the web in simplicity, without having to deal with the _massive_ fragmentation, framework war, and <sub>_shudders_</sub> CSS. |