Skip to content

About

TUI Framework in the style of tkinter

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Warning

This project is a work in progress and should not be considered production-ready.

CroissanTUI

A C++ TUI framework inspired by tkinter, easy to learn, fast to code, beginner friendly.

MIT License Dev build Build from source: C++20 Precompiled .lib: C++17


Resources


CroissanTUI is an easy-to-use C++ Text User Interface (TUI) framework for cross-platform applications, inspired by Python's tkinter. It's perfect for smaller projects.

Key features:

  • Keyword Arguments: instead of data objects like struct ButtonConfig to configure widgets, CroissanTUI uses keyword arguments inspired by Python's **kwargs.
  • Text Modifiers: different characters and words inside a Label can be rendered with different colors without having to create separate widgets, using TextStreams as a way to store text data.
    root.make_child<Label>(
        text << "Normal text | " 
            << Color::RED << "Red Text | " 
            << GraphicMod::ITALIC << "Italic red text |" 
            << GraphicMod::RESETALL << "Normal text") // <- Argument evaluates to a TextStream
  • Live Updates via Lambdas: TextStream tokens can also be std::function<std::string()>, letting a Label display live values by capturing a reference to an outside object — e.g. [&score]() { return std::to_string(score); } so the displayed value can change without recreating the widget.
    root.make_child<Label>( 
        text << "Score: " 
            << [&score]() { return std::to_string(score); },
        align = End);

Built with

Object Source build Precompiled Build Usage
C++ Language C++20 or newer C++17 Compilation
Python 3.4.x or newer N/A Header Generation
libgrapheme Vendored N/A Codepoint Iteration
utf8proc Submodule N/A Char-Width Calculation

Note: The library implementation uses C++20 features internally. The public API is compatible with C++17, so applications linking against the precompiled library only require a C++17 compiler.

Getting started

  1. Clone the repository into your third-party/vendor directory recursively.
git clone --recursive https://github.com/Aintdev/CroissanTUI.git
  1. Choose your preferred installation method
Install into your project

After cloning the repository, add the project to your CMakeLists.txt. Note: replace ${CMAKE_CURRENT_SOURCE_DIR}/third-party/CroissanTUI with the path to the CroissanTUI repository.

# Add CroissanTUI
add_subdirectory(
    "${CMAKE_CURRENT_SOURCE_DIR}/third-party/CroissanTUI"
    "${CMAKE_CURRENT_BINARY_DIR}/CroissanTUI"
)

# Link CroissanTUI
target_link_libraries(MyApp PRIVATE CroissanTUI)

Then, run your project's CMake configuration/build.

Install via Sample Project

After cloning the repository, navigate to CroissanTUI/Scripts/ and run the appropriate setup script for your platform:

  • Linux: Sample-Setup-Linux.sh
  • Windows: Sample-Setup-Windows.bat

Once CMake has finished configuring the project, navigate to CroissanTUI/Sample/build/. You will find the generated project files for your CMake-compatible IDE there.

Usage

  1. Include the generated header file in a translation unit.
#include <ctui_c.h>

Note: Your IDE may not find the header file at first. This is not a problem since it will be created at build time of the library.

  1. Begin coding
Expand/Collapse code
#include <ctui_c.h>

using namespace ctui;
using enum Align;

int main()
{
    auto screen = Screen::make();

    auto root = screen->make_child<VStack>(
        pady = 2,
        halign = Center,
        fill = true
    );

    auto my_label = root->make_child<Label>(
        text << "Normal text | "
        << Color::RED << "Red Text | "
        << GraphicMod::ITALIC << "Italic red text | "
        << GraphicMod::RESET_ALL << "Normal text"
        << "\n☺️☺️☺️☺️☺️☺️☺️☺️\n|",
        halign = End
    );

    screen->run();
}

About

TUI Framework in the style of tkinter

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Contributors

Languages