Skip to main content

Python bindings for GTCaca, a libcaca-based terminal UI toolkit

Project description

GTCaca Python bindings

pybind11 bindings for GTCaca, the libcaca-based terminal UI toolkit in this repository.

The bindings compile the GTCaca C sources directly into the extension module, so the only external runtime dependency is libcaca itself — no separately installed libgtcaca is required.

Requirements

  • A C/C++ toolchain and CMake ≥ 3.20
  • libcaca with its development headers, discoverable via pkg-config (pkg-config --exists caca should succeed)
  • Python ≥ 3.8 and pybind11
  • (optional) oniguruma — not needed; only the editor widget uses it and it is not exposed here

Install

From this directory (src/bindings/python):

pip install .

This uses scikit-build-core to drive CMake and produces an importable gtcaca package.

Building in-tree without installing

cmake -S . -B build \
  -Dpybind11_DIR="$(python -m pybind11 --cmakedir)"
cmake --build build -j
# the compiled _gtcaca*.so lands in build/; add it to PYTHONPATH or copy it
# next to the gtcaca/ package directory.

Usage

import gtcaca as gt

gt.init()
gt.application_new("Hello")
win = gt.window_new(None, "Demo", 0, 1, 40, 10)
gt.label_new(win, "Press q to quit", 2, 2)

btn = gt.button_new(win, "  OK  ", 2, 4)
def on_key(key):
    if key == gt.KEY_RETURN:
        gt.main_quit()
    return 0          # 0 = event not consumed
btn.on_key(on_key)

win.set_focus()
gt.main()             # blocking event loop

See example.py for a fuller form with a menu, entries, checkbox, progress bar and status bar.

API overview

Factory functions create widgets and return widget objects; the first argument is the parent (a widget object, or None for top-level / canvas-anchored widgets):

Factory Returns Key methods
init(), main(), main_quit(), redraw() lifecycle
canvas_width(), canvas_height() int canvas size in cells
application_new(title) Application draw()
window_new(parent, title, x, y, w, h) Window set_focus, set_focused_child, set_default, focus_next_child, close
window_new_centered(parent, title, w, h) Window
label_new(parent, text, x, y) Label
button_new(parent, label, x, y) Button on_key(cb)
entry_new(parent, x, y, w) Entry get_text, set_text, set_secret, on_key
checkbox_new(parent, label, x, y) Checkbox get_checked, set_checked, on_key
radiobutton_new(parent, label, group_id, x, y) RadioButton get_active, set_active, on_key
combobox_new(parent, x, y, w) ComboBox append, get_selected, get_selected_index, on_key
progressbar_new(parent, x, y, w) ProgressBar set_value, get_value
textview_new(parent, x, y, w, h) TextView append, clear, set_mode, on_key
statusbar_new(text) StatusBar set_text, set_rows_from_bottom
menu_new() Menu add_entry, add_item, add_separator, handle_key

Every widget exposes the shared preamble (x, y, width, height, has_focus, is_visible, id) plus show(), hide(), and as_widget() (used internally for parent passing).

Callbacks

  • Key callbacks (on_key) receive the integer key and may return an int (0 = not consumed, the default if you return None). Key constants are exposed as module attributes: KEY_RETURN, KEY_ESCAPE, KEY_TAB, KEY_UP/KEY_DOWN/KEY_LEFT/KEY_RIGHT, KEY_F1, KEY_F10, etc.
  • Menu actions (the last argument to menu.add_item) take no arguments.
  • Exceptions raised inside a callback are reported via sys.unraisablehook and do not abort the event loop.

The GIL is released while gt.main() runs and re-acquired inside every callback, so callbacks can safely touch other Python state.

Scope

The toolkit ships ~40 widgets; these bindings currently cover the core lifecycle plus the widgets used in the C demo (demo/demo.c). Additional widgets (tree, table, tabs, calendar, charts, editor, hexview, …) follow the exact same pattern in gtcaca_module.cpp — bind the struct with bind_common, add a *_new factory with a return_value_policy::reference, and wire any callback through the shared trampoline.

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

gtcaca-0.1.15.tar.gz (342.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

gtcaca-0.1.15-cp313-cp313-manylinux_2_28_x86_64.whl (920.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

gtcaca-0.1.15-cp313-cp313-manylinux_2_28_aarch64.whl (890.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

gtcaca-0.1.15-cp313-cp313-macosx_11_0_arm64.whl (517.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

gtcaca-0.1.15-cp312-cp312-manylinux_2_28_x86_64.whl (920.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

gtcaca-0.1.15-cp312-cp312-manylinux_2_28_aarch64.whl (890.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

gtcaca-0.1.15-cp312-cp312-macosx_11_0_arm64.whl (517.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

gtcaca-0.1.15-cp311-cp311-manylinux_2_28_x86_64.whl (919.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

gtcaca-0.1.15-cp311-cp311-manylinux_2_28_aarch64.whl (891.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

gtcaca-0.1.15-cp311-cp311-macosx_11_0_arm64.whl (515.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

gtcaca-0.1.15-cp310-cp310-manylinux_2_28_x86_64.whl (917.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

gtcaca-0.1.15-cp310-cp310-manylinux_2_28_aarch64.whl (889.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

gtcaca-0.1.15-cp310-cp310-macosx_11_0_arm64.whl (514.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

gtcaca-0.1.15-cp39-cp39-manylinux_2_28_x86_64.whl (918.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

gtcaca-0.1.15-cp39-cp39-manylinux_2_28_aarch64.whl (890.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ ARM64

gtcaca-0.1.15-cp39-cp39-macosx_11_0_arm64.whl (514.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file gtcaca-0.1.15.tar.gz.

File metadata

  • Download URL: gtcaca-0.1.15.tar.gz
  • Upload date:
  • Size: 342.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for gtcaca-0.1.15.tar.gz
Algorithm Hash digest
SHA256 0bf94ca944da4a79a422cd18258fe5c14ee5a52e244891c5531adbd9d8c24354
MD5 5629c8dfe769012eed181e6bbdc4d413
BLAKE2b-256 a4d65d25b3af397f3ec217f4502843784aa6f916261a1410305f2f69272bc1c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15.tar.gz:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 18927ca055eafc999799713d6a5560f5a02101d78dd202d6c0c9e924b8c97d06
MD5 1e24f1ed0a6e420f819097ba28a5e595
BLAKE2b-256 f9223570fe2051a927842f38a8a190a5944d63b8a224d7ec9366e575fe90c65e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e5b44b13396a58cda5bec2faea9fbfcea69e2957c3ad74e5422822a928bccac6
MD5 6ec7938db236e9247cde44700902f907
BLAKE2b-256 7462b5e2f810b229627d29da0d1a1c5316d87dea8a8d9ff323da0ebf122b4c0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp313-cp313-manylinux_2_28_aarch64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 60e25e258a94ef24326b05a7b259077d23b312d24bafb0332c0f371cb0d37c26
MD5 fdb9bef7ca713c8a95f8613d0b3b4c42
BLAKE2b-256 b5543302740bd3c084981670541ac74a7d012c0b617b7f883cd13ab91d6248c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 640d71ead04a53bd16debd2e2a294a330c7685115e8665ae211e66137994fcc9
MD5 e811bf6c705a2f60ec4b56d97cf5ed9c
BLAKE2b-256 433f946e3bfc31c134e870b9ffafc066f39b97651b8c3fe4e7f1d45d69f6c29b

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4f181235d31e6decc638b9da0b7efc911f3d4382183552b665cfffa062c1913f
MD5 6330b7d2e51c71dd06ec78ea7466e702
BLAKE2b-256 c51c56ecd537faba7e33e53b43a563e4d9a71d252c909f41f992d3789736e072

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp312-cp312-manylinux_2_28_aarch64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fade78691bdfc36f2c14231ed7576a02c9fe97a2eb48645b798d8f609e8b9a28
MD5 26ca9ef23eb4989e0d9defe1ae7e94c8
BLAKE2b-256 7423989811fa46c06f032b582e015796ed7bb2f7f3be50bbbe7d65731e0dcfe3

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e6c2d2b1ff41a1de535f4cd277a914e603bdbd68363ac1dc9d6014936ae9b659
MD5 c9a65d39bca0d30d9dc0fef8fe6274aa
BLAKE2b-256 9572d798dae3713a53abe128b9705c0a3ab278702cec8ec58d37ad61afe813ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c298291cbae92f4bd86a8c8e8aecda1e0d96184bb8af49aec651aadc0d1a714b
MD5 e24556cd2dade119043b4ad906233b32
BLAKE2b-256 c62a4ca690c3d54c150fbcc55ce6e4fb9e70a2bd9579c7e246e406e220c5e03f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp311-cp311-manylinux_2_28_aarch64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 97460f3598597b4ab6691886e9444df6883a2c5cb0da146df32d3228f1247595
MD5 dd13a26b7cbe4225ae784e904d4cea20
BLAKE2b-256 92c9c1799e7f9ff9d1abc478e1483f675c309fc4ea158ccd092eb2c94feff571

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e49ca6ba4ea4dfebb445a52a509bb87005894d881da8aa1204b596fd9f210f14
MD5 192c6eec405bed5901d1090d7bbc3784
BLAKE2b-256 9dd14dc94d0c256034344da993785b8698e087fc0c89ba2f7ec77378fe84e12e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 81abe4c7a0958244a76fd36ccf06afbd5ca5158d4350f7effa517b35ad6bac11
MD5 33d24ee184f99c2c1e611b7a4028ec17
BLAKE2b-256 a35542a7076dc106585ff20a4196b3e60aba868337ae3f1ad7c9cb6aed8105c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp310-cp310-manylinux_2_28_aarch64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02bdd4214c95e325e6a37981e68d5add89d8d375756b02e210c0b8a017aa61de
MD5 8529c786aa1b66423648e8682ff6711e
BLAKE2b-256 bee23f583a4489a00a29eb65dfd803e18baffe47b7dc3c027f20f8b2e82cd67f

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 93c0ffff67e94d346d9dd57f312c985f57c25cee14574a1d0d2f0a64da9a0003
MD5 abd5acf0421dc4e5f63042e6807bc2e9
BLAKE2b-256 c05bded5cb8c6044f37c7219b5dd54e61dcf8a4d73b4b77e104a6dccc33e0976

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp39-cp39-manylinux_2_28_x86_64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp39-cp39-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp39-cp39-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cbb2cec5e6a7c6e220c415ecc5c37e5e699018ae438505684102d8a9ecb854ef
MD5 e36ab21b27bc9da103f748676dc552ec
BLAKE2b-256 0d1c1eb9ab7c54e5a31602ab24ad1d1ff700f159546f3de12f3e38bcc9dd7611

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp39-cp39-manylinux_2_28_aarch64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtcaca-0.1.15-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for gtcaca-0.1.15-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 64c2c646efed664cfd25ec0d892d79820bcfa6c8416f84b92c4e958364817182
MD5 445f50703416aad6d5276ba603eb6d79
BLAKE2b-256 aca12dfab5f55110024153e295a06fa4c2849f12f9c694e430c0dac60b882949

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtcaca-0.1.15-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on stricaud/gtcaca

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page