<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged truegraphics</title>
<link>https://coderlegion.com/tag/truegraphics</link>
<description>Powered by Question2Answer</description>
<item>
<title>TrueGraphics</title>
<link>https://coderlegion.com/12887/truegraphics</link>
<description>&lt;h2 id=&quot;truegraphics&quot;&gt;TrueGraphics&lt;/h2&gt;
&lt;p&gt;TrueGraphics is a small Windows-only GUI experiment: a C++ core (Win32 + GDI) with Python bindings built using &lt;code&gt;pybind11&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;overview&quot;&gt;Overview&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Windows-only Win32 window + message loop&lt;/li&gt;
&lt;li&gt;Lightweight GDI renderer (double-buffered)&lt;/li&gt;
&lt;li&gt;Python-first authoring model (&lt;code&gt;@app.window&lt;/code&gt; builder function)&lt;/li&gt;
&lt;li&gt;Nested UI via container context managers (&lt;code&gt;with tg.Row(): ...&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Basic layouts: &lt;code&gt;Row&lt;/code&gt;, &lt;code&gt;Column&lt;/code&gt;, &lt;code&gt;Grid&lt;/code&gt;, &lt;code&gt;Absolute&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Basic styling setters on widgets (colors, radius, borders, padding/margin)&lt;/li&gt;
&lt;li&gt;Canvas drawing API (&lt;code&gt;draw_line/rect/circle/text&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Image widget (&lt;code&gt;tg.Image(&quot;path&quot;)&lt;/code&gt;) via GDI+&lt;/li&gt;
&lt;li&gt;Animations (&lt;code&gt;widget.animate(...)&lt;/code&gt;), timers (&lt;code&gt;app.set_timeout/set_interval&lt;/code&gt;), and background tasks (&lt;code&gt;app.run_async&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Scrolling: &lt;code&gt;tg.ScrollView()&lt;/code&gt; + mouse wheel&lt;/li&gt;
&lt;li&gt;Multi-window apps via &lt;code&gt;app.add_window(...)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;System tray icon via &lt;code&gt;app.enable_tray(...)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Resources: &lt;code&gt;tg.add_resource_path(...)&lt;/code&gt;, &lt;code&gt;tg.resolve_resource(...)&lt;/code&gt;, &lt;code&gt;tg.load_font(...)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Widgets: &lt;code&gt;Button&lt;/code&gt;, &lt;code&gt;Label&lt;/code&gt;, &lt;code&gt;TextBox&lt;/code&gt;, &lt;code&gt;PasswordBox&lt;/code&gt;, &lt;code&gt;TextArea&lt;/code&gt;, &lt;code&gt;Checkbox&lt;/code&gt;, &lt;code&gt;RadioButton&lt;/code&gt;, &lt;code&gt;Slider&lt;/code&gt;, &lt;code&gt;ProgressBar&lt;/code&gt;, &lt;code&gt;Dropdown&lt;/code&gt;, &lt;code&gt;Tabs&lt;/code&gt;, &lt;code&gt;ListView&lt;/code&gt;, &lt;code&gt;Table&lt;/code&gt;, &lt;code&gt;TreeView&lt;/code&gt;, &lt;code&gt;Container&lt;/code&gt;, &lt;code&gt;ScrollView&lt;/code&gt;, &lt;code&gt;Canvas&lt;/code&gt;, &lt;code&gt;Image&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;State: &lt;code&gt;StateInt&lt;/code&gt;, &lt;code&gt;StateFloat&lt;/code&gt;, &lt;code&gt;StateBool&lt;/code&gt;, &lt;code&gt;StateString&lt;/code&gt; (all with &lt;code&gt;subscribe(...)&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Buildable with &lt;code&gt;pip install .&lt;/code&gt; (requires a C++ toolchain)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;installation&quot;&gt;Installation&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install truegraphics
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pip install .
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;see-manual-to-get-more-information-about-how-to-use-&quot;&gt;See &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/LegedsDaD/TrueGraphics/blob/main/MANUAL.md&quot;&gt;Manual&lt;/a&gt; to get more information about , how to use .&lt;/h3&gt;
&lt;p&gt;Requirements (Windows):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Python 3.9+&lt;/li&gt;
&lt;li&gt;CMake 3.20+&lt;/li&gt;
&lt;li&gt;A C++ toolchain: MSVC (Visual Studio Build Tools) or MinGW-w64 (MSYS2)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;if-downloading-using-pip-install-&quot;&gt;If downloading using &lt;code&gt;pip install .&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;MinGW note:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;MinGW builds work, but image support requires &lt;code&gt;gdiplus&lt;/code&gt; (linked automatically via CMake when using a toolchain that provides it).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;example-usage&quot;&gt;Example Usage&lt;/h3&gt;
&lt;p&gt;Minimal app:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import truegraphics as tg

app = tg.App()

@app.window
def main():
    btn = tg.Button(&quot;Hello World&quot;)
    btn.set_background(&quot;#3A7AFE&quot;)
    btn.set_text_color(&quot;#FFFFFF&quot;)

app.run()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Layout example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import truegraphics as tg

app = tg.App()
app.set_title(&quot;Row / Grid Demo&quot;)

@app.window
def main():
    with tg.Row() as row:
        row.set_gap(12)
        row.set_align(tg.Align.Center)
        tg.Button(&quot;OK&quot;)
        tg.Button(&quot;Cancel&quot;)

    with tg.Grid(2) as grid:
        grid.set_gap(10)
        tg.TextBox(&quot;Type here...&quot;)
        tg.Checkbox(&quot;Enable feature&quot;, checked=True)

app.run()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Counter app (manual UI update via &lt;code&gt;StateInt.subscribe&lt;/code&gt;):&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;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&quot;Count: {value}&quot;)

    counter.subscribe(update_label)

    tg.Button(&quot;Increment&quot;, on_click=lambda: counter.set(counter.get() + 1))
    label = tg.Label(f&quot;Count: {counter.get()}&quot;)

app.run()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Canvas example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;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, &quot;#3A7AFE&quot;, 3)
    canvas.draw_rect(20, 60, 160, 80, &quot;#22C55E&quot;, radius=12, filled=True)
    canvas.draw_circle(120, 200, 40, &quot;#F97316&quot;, filled=True)
    canvas.draw_text(20, 260, &quot;Hello Canvas&quot;, &quot;#E5E7EB&quot;)

app.run()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Image example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import truegraphics as tg

app = tg.App()
app.set_title(&quot;Image Demo&quot;)

@app.window
def main():
    img = tg.Image(&quot;assets/logo.png&quot;)
    img.set_size(320, 180)

app.run()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Multi-window example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import truegraphics as tg

app = tg.App()
app.set_title(&quot;Main window&quot;)

@app.window
def main():
    tg.Label(&quot;Main&quot;)

def second():
    tg.Label(&quot;Second window&quot;)

app.add_window(second, title=&quot;Second&quot;, width=420, height=220)
app.run()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;System tray example:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;import truegraphics as tg

app = tg.App()
app.enable_tray(&quot;assets/app.ico&quot;, &quot;TrueGraphics&quot;, on_click=lambda: tg.message_box(&quot;Tray clicked&quot;, &quot;Tray&quot;))

@app.window
def main():
    tg.Label(&quot;Running (see tray icon)&quot;)

app.run()
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;showcase-example&quot;&gt;Showcase Example&lt;/h3&gt;
&lt;p&gt;Run the full showcase (widgets, layouts, canvas, events, async, drag-drop, multi-window, tray):&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;python examples/showcase.py
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;current-limitations-important-&quot;&gt;Current Limitations (important)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Windows only (Win32 + GDI).&lt;/li&gt;
&lt;li&gt;Rendering is GDI-based (no GPU backend yet).&lt;/li&gt;
&lt;li&gt;Text rendering/editing is basic (no IME, no word-wrapping; caret/selection are approximate).&lt;/li&gt;
&lt;li&gt;Clipboard is text-only for now (CF_TEXT).&lt;/li&gt;
&lt;li&gt;Drag-and-drop supports file drops (WM_DROPFILES) only.&lt;/li&gt;
&lt;li&gt;Resource management is intentionally small: search paths + font file loading.&lt;/li&gt;
&lt;li&gt;System tray support is minimal (one tray icon per window; basic right-click menu).&lt;/li&gt;
&lt;li&gt;Not all “standard toolkit widgets” exist yet (this is still early-stage).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;known-gaps&quot;&gt;Known Gaps&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;No IME / complex text shaping.&lt;/li&gt;
&lt;li&gt;No layout-driven text measurement or wrapping.&lt;/li&gt;
&lt;li&gt;No accessibility and no cross-platform backend.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;architecture-overview&quot;&gt;Architecture Overview&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;engine/include/truegraphics&lt;/code&gt;: public engine headers&lt;/li&gt;
&lt;li&gt;&lt;code&gt;engine/src&lt;/code&gt;: engine implementation&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bindings/module.cpp&lt;/code&gt;: pybind11 module&lt;/li&gt;
&lt;li&gt;&lt;code&gt;python/truegraphics&lt;/code&gt;: Python package surface&lt;/li&gt;
&lt;li&gt;&lt;code&gt;examples&lt;/code&gt;: runnable examples&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;notes&quot;&gt;Notes&lt;/h3&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;h3 id=&quot;help-truegraphics-to-get-compatible-with-macos-and-linux-&quot;&gt;Help TrueGraphics to get compatible with MacOS and Linux .&lt;/h3&gt;
&lt;h3 id=&quot;thank-you-for-taking-time-to-see-the-project-&quot;&gt;Thank You for taking time to see the project .&lt;/h3&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/12887/truegraphics</guid>
<pubDate>Sun, 15 Mar 2026 08:56:06 +0000</pubDate>
</item>
</channel>
</rss>