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
Metadata
Release files for truegraphics 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| truegraphics-1.0.0.tar.gz | 993.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| truegraphics-1.0.0-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| truegraphics-1.0.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| truegraphics-1.0.0-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| truegraphics-1.0.0-cp310-cp310-win_amd64.whl | CPython 3.10 | CPython 3.10 | Windows x86-64 | Details |
| truegraphics-1.0.0-cp39-cp39-win_amd64.whl | CPython 3.9 | CPython 3.9 | Windows x86-64 | Details |
Total release size: 7.2 MB
Release files / truegraphics-1.0.0.tar.gz
| Download URL | truegraphics-1.0.0.tar.gz |
|---|---|
| Size | 993.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a9899c7a7d87bca19059f304142abe864fe7e0d011a137d3fce01e703d05f38
|
|
BLAKE2b-256 checksum How to use checksums |
e5c668bcd51a2528458ad5a7a1f9d866dde3ff0059de1a0988dc55bc2430ecfd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / truegraphics-1.0.0-cp313-cp313-win_amd64.whl
| Download URL | truegraphics-1.0.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a5557f2d83d79ba553247a8b796074c8e7538eb0efd0cbeccea5f09ea1d0a24a
|
|
BLAKE2b-256 checksum How to use checksums |
7b56e6869f2a24dccd1851f861d4951d12aa7ed594c31b2301b1dd003e1bfc13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / truegraphics-1.0.0-cp312-cp312-win_amd64.whl
| Download URL | truegraphics-1.0.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ad2bbdd65ea57aaa3065489e1a5c5967adc052de1bffbf58fc7de53c660a7df9
|
|
BLAKE2b-256 checksum How to use checksums |
f5829a084ccec3f786a82c13fceff1333eead4e02bf2f545539f44fecad0bed4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / truegraphics-1.0.0-cp311-cp311-win_amd64.whl
| Download URL | truegraphics-1.0.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f83cc3302747917e33377c10136c9d05c1126f1b4d483e95d43f2bb242f19049
|
|
BLAKE2b-256 checksum How to use checksums |
004fa9a011c8b4ed36e48291b91d595179df42ba90ac1b7d06d659e89d873048
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / truegraphics-1.0.0-cp310-cp310-win_amd64.whl
| Download URL | truegraphics-1.0.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
242ff0eecaeb01dea1c70d588af46f9477afba1684c0da2fbab62436cf22fffb
|
|
BLAKE2b-256 checksum How to use checksums |
281ec648c0136507cd5e37c9747d082716d20485fbf58fa1493da0858db1b97e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency logRelease files / truegraphics-1.0.0-cp39-cp39-win_amd64.whl
| Download URL | truegraphics-1.0.0-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
46d97bd7e8e0f62d1f937242b9c729566d45315061e94d7ced2b51c6cecfb9fc
|
|
BLAKE2b-256 checksum How to use checksums |
1a6495fe9bf5a604a38a056fb67bd50975cea7d86914d88fa89c65baf055e54e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.
Transparency log