TrueGraphics: a C++-accelerated GUI and graphics framework with Python bindings
Project description
TrueGraphics
TrueGraphics is a small Windows-only GUI experiment: a C++ core (Win32 + GDI) with Python bindings built using pybind11.
Overview
- Windows-only Win32 window + message loop
- Lightweight GDI renderer (double-buffered)
- Python-first authoring model (
@app.windowbuilder function) - Nested UI via container context managers (
with tg.Row(): ...) - Basic layouts:
Row,Column,Grid,Absolute - Basic styling setters on widgets (colors, radius, borders, padding/margin)
- Canvas drawing API (
draw_line/rect/circle/text) - Image widget (
tg.Image("path")) via GDI+ - Animations (
widget.animate(...)), timers (app.set_timeout/set_interval), and background tasks (app.run_async) - Scrolling:
tg.ScrollView()+ mouse wheel - Multi-window apps via
app.add_window(...) - System tray icon via
app.enable_tray(...) - Resources:
tg.add_resource_path(...),tg.resolve_resource(...),tg.load_font(...) - Widgets:
Button,Label,TextBox,PasswordBox,TextArea,Checkbox,RadioButton,Slider,ProgressBar,Dropdown,Tabs,ListView,Table,TreeView,Container,ScrollView,Canvas,Image - State:
StateInt,StateFloat,StateBool,StateString(all withsubscribe(...)) - Buildable with
pip install .(requires a C++ toolchain)
Installation
pip install .
Requirements (Windows):
- Python 3.9+
- CMake 3.20+
- A C++ toolchain: MSVC (Visual Studio Build Tools) or MinGW-w64 (MSYS2)
MinGW note:
- MinGW builds work, but image support requires
gdiplus(linked automatically via CMake when using a toolchain that provides it).
Example Usage
Minimal app:
import truegraphics as tg
app = tg.App()
@app.window
def main():
btn = tg.Button("Hello World")
btn.set_background("#3A7AFE")
btn.set_text_color("#FFFFFF")
app.run()
Layout example:
import truegraphics as tg
app = tg.App()
app.set_title("Row / Grid Demo")
@app.window
def main():
with tg.Row() as row:
row.set_gap(12)
row.set_align(tg.Align.Center)
tg.Button("OK")
tg.Button("Cancel")
with tg.Grid(2) as grid:
grid.set_gap(10)
tg.TextBox("Type here...")
tg.Checkbox("Enable feature", checked=True)
app.run()
Counter app (manual UI update via StateInt.subscribe):
import truegraphics as tg
app = tg.App()
counter = tg.StateInt(0)
label = None
@app.window
def main():
global label
def update_label(value: int):
if label is not None:
label.set_text(f"Count: {value}")
counter.subscribe(update_label)
tg.Button("Increment", on_click=lambda: counter.set(counter.get() + 1))
label = tg.Label(f"Count: {counter.get()}")
app.run()
Canvas example:
import truegraphics as tg
app = tg.App()
@app.window
def main():
canvas = tg.Canvas()
canvas.set_size(520, 300)
canvas.draw_line(20, 20, 240, 40, "#3A7AFE", 3)
canvas.draw_rect(20, 60, 160, 80, "#22C55E", radius=12, filled=True)
canvas.draw_circle(120, 200, 40, "#F97316", filled=True)
canvas.draw_text(20, 260, "Hello Canvas", "#E5E7EB")
app.run()
Image example:
import truegraphics as tg
app = tg.App()
app.set_title("Image Demo")
@app.window
def main():
img = tg.Image("assets/logo.png")
img.set_size(320, 180)
app.run()
Multi-window example:
import truegraphics as tg
app = tg.App()
app.set_title("Main window")
@app.window
def main():
tg.Label("Main")
def second():
tg.Label("Second window")
app.add_window(second, title="Second", width=420, height=220)
app.run()
System tray example:
import truegraphics as tg
app = tg.App()
app.enable_tray("assets/app.ico", "TrueGraphics", on_click=lambda: tg.message_box("Tray clicked", "Tray"))
@app.window
def main():
tg.Label("Running (see tray icon)")
app.run()
Showcase Example
Run the full showcase (widgets, layouts, canvas, events, async, drag-drop, multi-window, tray):
python examples/showcase.py
Current Limitations (important)
- Windows only (Win32 + GDI).
- Rendering is GDI-based (no GPU backend yet).
- Text rendering/editing is basic (no IME, no word-wrapping; caret/selection are approximate).
- Clipboard is text-only for now (CF_TEXT).
- Drag-and-drop supports file drops (WM_DROPFILES) only.
- Resource management is intentionally small: search paths + font file loading.
- System tray support is minimal (one tray icon per window; basic right-click menu).
- Not all “standard toolkit widgets” exist yet (this is still early-stage).
Known Gaps
- No IME / complex text shaping.
- No layout-driven text measurement or wrapping.
- No accessibility and no cross-platform backend.
Architecture Overview
engine/include/truegraphics: public engine headersengine/src: engine implementationbindings/module.cpp: pybind11 modulepython/truegraphics: Python package surfaceexamples: runnable examples
Notes
This version targets Windows and uses an internal Win32-backed event loop with an engine-side scene/widget model. Rendering is implemented as a lightweight internal renderer abstraction that currently uses GDI-based drawing while preserving the C++ engine architecture for future GPU backend expansion.
Releases (Wheels + PyPI Trusted Publishing)
This repo includes GitHub Actions workflows to build Windows wheels and publish them to PyPI using PyPI “Trusted Publishing” (OIDC):
- CI wheel builds:
.github/workflows/ci.yml - Publish on tags
v*:.github/workflows/publish.yml
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file truegraphics-1.0.0.tar.gz.
File metadata
- Download URL: truegraphics-1.0.0.tar.gz
- Upload date:
- Size: 993.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a9899c7a7d87bca19059f304142abe864fe7e0d011a137d3fce01e703d05f38
|
|
| MD5 |
c1a27d26b3b9ac9c644f16f93714f4a4
|
|
| BLAKE2b-256 |
e5c668bcd51a2528458ad5a7a1f9d866dde3ff0059de1a0988dc55bc2430ecfd
|
Provenance
The following attestation bundles were made for truegraphics-1.0.0.tar.gz:
Publisher:
publish.yml on LegedsDaD/TrueGraphics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truegraphics-1.0.0.tar.gz -
Subject digest:
9a9899c7a7d87bca19059f304142abe864fe7e0d011a137d3fce01e703d05f38 - Sigstore transparency entry: 1102635922
- Sigstore integration time:
-
Permalink:
LegedsDaD/TrueGraphics@c2472abc66842dd862c12075b4314b123ca6c74e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/LegedsDaD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c2472abc66842dd862c12075b4314b123ca6c74e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file truegraphics-1.0.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: truegraphics-1.0.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5557f2d83d79ba553247a8b796074c8e7538eb0efd0cbeccea5f09ea1d0a24a
|
|
| MD5 |
c08575290dc8189ff49b615782e936aa
|
|
| BLAKE2b-256 |
7b56e6869f2a24dccd1851f861d4951d12aa7ed594c31b2301b1dd003e1bfc13
|
Provenance
The following attestation bundles were made for truegraphics-1.0.0-cp313-cp313-win_amd64.whl:
Publisher:
publish.yml on LegedsDaD/TrueGraphics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truegraphics-1.0.0-cp313-cp313-win_amd64.whl -
Subject digest:
a5557f2d83d79ba553247a8b796074c8e7538eb0efd0cbeccea5f09ea1d0a24a - Sigstore transparency entry: 1102635926
- Sigstore integration time:
-
Permalink:
LegedsDaD/TrueGraphics@c2472abc66842dd862c12075b4314b123ca6c74e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/LegedsDaD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c2472abc66842dd862c12075b4314b123ca6c74e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file truegraphics-1.0.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: truegraphics-1.0.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad2bbdd65ea57aaa3065489e1a5c5967adc052de1bffbf58fc7de53c660a7df9
|
|
| MD5 |
1912774693976ef7eef1fc49010f4a41
|
|
| BLAKE2b-256 |
f5829a084ccec3f786a82c13fceff1333eead4e02bf2f545539f44fecad0bed4
|
Provenance
The following attestation bundles were made for truegraphics-1.0.0-cp312-cp312-win_amd64.whl:
Publisher:
publish.yml on LegedsDaD/TrueGraphics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truegraphics-1.0.0-cp312-cp312-win_amd64.whl -
Subject digest:
ad2bbdd65ea57aaa3065489e1a5c5967adc052de1bffbf58fc7de53c660a7df9 - Sigstore transparency entry: 1102635928
- Sigstore integration time:
-
Permalink:
LegedsDaD/TrueGraphics@c2472abc66842dd862c12075b4314b123ca6c74e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/LegedsDaD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c2472abc66842dd862c12075b4314b123ca6c74e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file truegraphics-1.0.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: truegraphics-1.0.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f83cc3302747917e33377c10136c9d05c1126f1b4d483e95d43f2bb242f19049
|
|
| MD5 |
446422b1237268fe62c300e108c4385c
|
|
| BLAKE2b-256 |
004fa9a011c8b4ed36e48291b91d595179df42ba90ac1b7d06d659e89d873048
|
Provenance
The following attestation bundles were made for truegraphics-1.0.0-cp311-cp311-win_amd64.whl:
Publisher:
publish.yml on LegedsDaD/TrueGraphics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truegraphics-1.0.0-cp311-cp311-win_amd64.whl -
Subject digest:
f83cc3302747917e33377c10136c9d05c1126f1b4d483e95d43f2bb242f19049 - Sigstore transparency entry: 1102635930
- Sigstore integration time:
-
Permalink:
LegedsDaD/TrueGraphics@c2472abc66842dd862c12075b4314b123ca6c74e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/LegedsDaD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c2472abc66842dd862c12075b4314b123ca6c74e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file truegraphics-1.0.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: truegraphics-1.0.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
242ff0eecaeb01dea1c70d588af46f9477afba1684c0da2fbab62436cf22fffb
|
|
| MD5 |
27cfe2b09724736791a730c0666e9cc2
|
|
| BLAKE2b-256 |
281ec648c0136507cd5e37c9747d082716d20485fbf58fa1493da0858db1b97e
|
Provenance
The following attestation bundles were made for truegraphics-1.0.0-cp310-cp310-win_amd64.whl:
Publisher:
publish.yml on LegedsDaD/TrueGraphics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truegraphics-1.0.0-cp310-cp310-win_amd64.whl -
Subject digest:
242ff0eecaeb01dea1c70d588af46f9477afba1684c0da2fbab62436cf22fffb - Sigstore transparency entry: 1102635924
- Sigstore integration time:
-
Permalink:
LegedsDaD/TrueGraphics@c2472abc66842dd862c12075b4314b123ca6c74e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/LegedsDaD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c2472abc66842dd862c12075b4314b123ca6c74e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file truegraphics-1.0.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: truegraphics-1.0.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46d97bd7e8e0f62d1f937242b9c729566d45315061e94d7ced2b51c6cecfb9fc
|
|
| MD5 |
952d74017c3ad046ba76d7464816a5e1
|
|
| BLAKE2b-256 |
1a6495fe9bf5a604a38a056fb67bd50975cea7d86914d88fa89c65baf055e54e
|
Provenance
The following attestation bundles were made for truegraphics-1.0.0-cp39-cp39-win_amd64.whl:
Publisher:
publish.yml on LegedsDaD/TrueGraphics
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truegraphics-1.0.0-cp39-cp39-win_amd64.whl -
Subject digest:
46d97bd7e8e0f62d1f937242b9c729566d45315061e94d7ced2b51c6cecfb9fc - Sigstore transparency entry: 1102635923
- Sigstore integration time:
-
Permalink:
LegedsDaD/TrueGraphics@c2472abc66842dd862c12075b4314b123ca6c74e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/LegedsDaD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c2472abc66842dd862c12075b4314b123ca6c74e -
Trigger Event:
workflow_dispatch
-
Statement type: