C 和 C++。使用 CMake 3.20+ 和 C11 / C++20 编译器(MSVC, GCC 或 MinGW-w64, 或 Clang)从源码构建;在 Linux 上,还需要 X11 头文件:
git clone https://github.com/ppmpreetham/BUI && cd BUI cmake -S . -B build cmake –build build -j 2 ctest –test-dir build # 可选:运行测试套件
在您自己的 CMake 项目中,将 BUI 添加为子目录并链接 bui::kit(或针对 Dear ImGui 链接 bui::imgui):
add_subdirectory(BUI) target_link_libraries(myapp PRIVATE bui::kit)
Dear ImGui。Python 用户可通过 pip install blenderui 安装(import blenderui.imgui)。C++ 链接 bui::imgui,C 链接 bui_cimgui。Rust 使用 blenderui-imgui crate:
cargo add blenderui-imgui
如果出现问题:
更多信息请参阅:docs/getting-started.md 以及网站上的 安装 BUI。
无需修改一行代码即可在 BUI 上运行任何 tkinter 程序:
blenderui-tk my_app.py # 等同于: python -m bui.tksyntax my_app.py
blenderui-tk 使 import tkinter 在该次运行中返回 BUI 的实现。或者也可以在代码中选择加入:
import blenderui.tksyntax as tk from blenderui.tksyntax import ttk, messagebox
root = tk.Tk() name = tk.StringVar(value=“Cube”) ttk.Entry(root, textvariable=name).pack(fill=“x”, padx=8, pady=8) ttk.Button(root, text=“Greet”, command=lambda: messagebox.showinfo(“Hi”, “Hello " + name.get())).pack() root.mainloop()
未修改的 tkinter 和 ttk 程序(examples/site/tk_export.py, ttk_queue.py)。
数字字段(Spinbox, Scale)的拖拽方式与 Blender 一致,支持 Ctrl+Z / Ctrl+Shift+Z 撤销编辑,且 filedialog 会打开 Blender 的文件浏览器。指南:docs/tkinter.md。
from blenderui.components import App, Panel, NumberSlider, VectorField, Checkbox, ColorSwatch, Button
App(“Object”, (420, 520), Panel(“Transform”, VectorField(“Location”, (0.0, 1.25, 0.0)), NumberSlider(“Scale”, 1.0, min=0, max=10, on_change=print)), Panel(“Shading”, Checkbox(“Shadows”, True), ColorSwatch(“Color”, (0.8, 0.3, 0.1, 1.0))), Button(“Apply”, on_click=lambda: print(“apply”)), ).run()
使用组件构建的渲染属性编辑器(examples/site/render_props.py)。
共有 45 个组件:布局、数值、按钮、视图、菜单和饼形菜单、颜色选择器、颜色渐变、曲线和节点编辑器、区域和模板。参考:docs/components.md。
编写 Qt 风格的 Python。除了 import 语句与 PySide 或 PyQt 不同外,其余完全一致,且无需安装后者:
import sys from blenderui.qtsyntax import (QApplication, QWidget, QVBoxLayout, QFormLayout, QLineEdit, QComboBox, QSlider, QProgressBar, QPushButton, QLabel, Qt)
app = QApplication(sys.argv) window = QWidget() window.setWindowTitle(“Export”) layout = QVBoxLayout(window)
form = QFormLayout() kind = QComboBox() kind.addItems([“glTF”, “FBX”, “OBJ”]) quality = QSlider(Qt.Horizontal) quality.setRange(0, 100) form.addRow(“Format:”, kind) form.addRow(“Quality:”, quality) layout.addLayout(form)
bar = QProgressBar() quality.valueChanged.connect(bar.setValue) layout.addWidget(bar)
status = QLabel(“Ready.”) go = QPushButton(“Export”) go.clicked.connect(lambda: status.setText(“Exporting as " + kind.currentText())) layout.addWidget(status) layout.addWidget(go)
window.show() sys.exit(app.exec())
Qt 语法(examples/site/qt_material.py)。
Qt 语法是部分实现的(主组件类中约 24% 的 Qt 方法名可用);缺失的部分会抛出 AttributeError。指南:docs/qt.md。
BUI 的 Rust crate 拥有两种一流语法,它们可以绘制相同的窗口:
在 rsx! 中(见 bindings/rust/blenderui/examples/hello.rs;在 bindings/rust 中运行 cargo run --release --example hello):
use blenderui::prelude starred;
#[component]
fn counter(label: &str) {
let (count, set_count) = use_state(0);
rsx! {
<div flex items-center gap-3 p-4 rounded-xl bg-zinc-800>
<span text-zinc-300>{label.to_string()} ": " {count().to_string()}</span>
<div px-3 py-1 rounded-md bg-sky-700 hover:bg-sky-500 onClick={move || set_count(count() + 1)}>
"Add one"
</div>
</div>
}
}
struct Hello;
impl Render for Hello {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
rsx! {
<body m-0 p-6 min-h-screen flex flex-col gap-4 bg-zinc-900 text-white>
<h1 text-2xl font-bold>"Hello, BUI"</h1>
<counter label="Clicks" />
<NumberSlider min={0.0} max={10.0} value="5" /> // 真正的 Blender 滑块
</body>
}
}
}
fn main() {
Application::new().run(|cx| {
cx.open_window(WindowOptions::default(), |_, cx| cx.new(|_| Hello)).unwrap();
});
}
在 gpui 构建器中,绘制相同的窗口:
use blenderui::prelude starred;
struct Hello { count: i32 }
impl Render for Hello {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let counter = div().flex().items_center().gap_3().p_4().rounded_xl().bg(rgb(0x27272a))
.child(span().text_color(rgb(0xd4d4d8)).child(format!("Clicks: {}", self.count)))
.child(div().px_3().py_1().rounded_md().bg(rgb(0x0369a1))
.hover(|s| s.bg(rgb(0x0ea5e9))).cursor_pointer()
.child("Add one")
.on_click(cx.listener(|this, _, _, cx| {
this.count += 1;
cx.notify();
})));
body().m_0().p_6().css("min-height", "100vh").flex().flex_col().gap_4()
.bg(rgb(0x18181b)).text_color(white())
.child(h1().text_2xl().font_bold().child("Hello, BUI"))
.child(counter)
.child(NumberSlider().min(0.0).max(10.0).value("5")) // 真正的 Blender 滑块
}
}
fn main() {
Application::new().run(|cx| {
cx.open_window(WindowOptions::default(), |_, cx| cx.new(|_| Hello { count: 0 })).unwrap();
});
}
Rust hello 示例:包含标题、计数器组件和 Blender 滑块。
这里有一个更大的示例,一个渲染农场仪表盘,分别用两种语法编写。两个程序绘制的像素完全相同:
渲染农场仪表盘:包含统计卡片的 CSS 网格、带有 Blender 进度条的任务行、节点列表、下拉菜单、按钮和复选框。
site_dashboard.rs (rsx!) 和 site_dashboard_builder.rs (gpui 构建器)。
指南:docs/rust.md 以及网站上的 Rust 教程。
/** @jsxImportSource @blender-ui/react */
import { render, useState, NumberSlider } from "@blender-ui/react"
function Counter() {
const [count, setCount] = useState(0) // React 的 hook,持有信号
return (
<main styled className="p-6 flex flex-col gap-3">
{/* `styled`: Blender 的外观 */}
<span>Clicks: {count}</span>
<button onClick={() => setCount((c) => c + 1)}>Add one</button>
<NumberSlider min={0} max={10} /> {/* Blender 组件 */}
</main>
)
}
render(<Counter />, { title: "Counter", width: 360, height: 200, gpu: true })
bun app.jsx # 运行它(Bun 直接读取 JSX)
npx bui build app.jsx # 或发布它:app.exe,一个 7 MB 的文件
如果不使用 React,@blender-ui/native 提供了一个类似 DOM 的 API:
const { App, signal } = require("@blender-ui/native”)
const app = new App({ gpu: true }) const win = app.window({ title: “Hello”, width: 360, height: 200 }) win.body.className = “m-0 p-6 flex flex-col gap-3 bg-[#2b2b2b] text-[#e6e6e6]”
const clicks = signal(0) const label = win.createElement(“span”) label.textContent = clicks // 跟随信号 const button = win.createElement(“button”) button.textContent = “Add one” button.addEventListener(“click”, () => clicks.value++) win.body.appendChild(label) win.body.appendChild(button)
React 在 BUI 上的任务列表(examples/site/js/todo_react.js);DOM 版本绘制效果相同。
Node.js 18+ 或 Bun。为 Windows x64 提供预构建版本;在 Linux 上,从源码构建插件(在 bindings/node 中运行 npm run build)即可获得原生窗口。指南:docs/javascript.md。
真实的 Dear ImGui 1.93 可以在 BUI 上运行:使用 BUI 的窗口、输入、CPU/GPU 渲染器、Blender 的主题和 Inter 字体。现有的 ImGui 代码无需修改即可编译。
#include “imgui.h” #include “imgui_impl_bui.h” // 见 examples/imgui_demo.cpp
static void frame(void*) { ImGui::ShowDemoWindow(); ImGui::Begin(“Hello”); static float v = 0.5f; ImGui::SliderFloat(“Value”, &v, 0.0f, 1.0f); ImGui::End(); }
int main() { ImGui::CreateContext(); ImGui_ImplBUI_App* app = ImGui_ImplBUI_Cr
eateApp(“Demo”, 1280, 800, frame, nullptr); ImGui_ImplBUI_RunApp(app); ImGui_ImplBUI_DestroyApp(app); ImGui::DestroyContext(); }
Python:
import blenderui.imgui as imgui # C: cimgui.h · Rust: the blenderui-imgui crate
state = {“value”: 0.5}
def frame(): imgui.show_demo_window() imgui.begin(“Hello”) _, state[“value”] = imgui.slider_float(“Value”, state[“value”], 0.0, 1.0) imgui.end()
imgui.run(frame, title=“Hello”, size=(1280, 800))
C (cimgui.h, cimgui conventions: ImGui_Button, ImGui_ButtonEx, and
the backend in cimgui_impl_bui.h) and Rust (blenderui-imgui) work the
same way:
use blenderui_imgui as imgui;
fn main() { let mut value = 0.5f32; imgui::run(“Hello”, [1280, 800], move || { imgui::show_demo_window(); imgui::begin(“Hello”); imgui::slider_float(“Value”, &mut value, 0.0, 1.0); imgui::end(); }); }
Build with -DBUI_IMGUI_BLENDER_WIDGETS=ON (or the Rust feature
blender-widgets) and ImGui’s widgets become Blender’s own: DragFloat is
Blender’s drag-to-scrub number field (Shift for precision, Ctrl to snap),
SliderFloat Blender’s number slider, checkboxes drag-toggle, menus and combos
get Blender’s menus. The rest of the ImGui API is unchanged. (The PyPI wheel
is built without it, so from Python you get ImGui’s own widgets in Blender’s
theme unless you build from source.)
Dear ImGui’s own demo with BUI_IMGUI_BLENDER_WIDGETS=ON: number fields, sliders, color rows and panel headers are Blender’s


The same ImGui code: ImGui’s widgets (left) and the Blender-widgets build (right) (examples/site/imgui_inspector.cpp)
Guide, coverage and the stock look: docs/imgui.md.
The kit’s API is one header, kit/include/BUI_kit.h, and it doubles as the
reference: every function has a one-line comment. This is a shortened
examples/kit_hello.c: a slider and a button in a
native window.
#include <stdio.h> #include “BUI_kit.h”
static void on_event(void *data, BKNode *node, int kind, void *ref, double a, double b) { if (kind == BK_EV_CLICK) printf(“clicked %s\n”, BK_get_str(node, “text”)); else if (kind == BK_EV_CHANGE) printf("%s = %g\n”, BK_get_str(node, “label”), BK_get_num(node, “value”)); }
int main(void) { BKNode root = BK_node_new(“frame”); / everything is a node / BK_set_num(root, “padding”, 8); / configured by property name */
BKNode size = BK_node_new(“slider”); BK_set_str(size, “label”, “Size”); BK_set_num(size, “max”, 10); BK_set_num(size, “value”, 2.5); BK_node_add(root, size, -1); BK_geom_set_manager(size, BK_GEOM_PACK); / Tk’s packer, in C */ BK_geom_set(size, “fill”, 1);
BKNode *apply = BK_node_new(“button”); BK_set_str(apply, “text”, “Apply”); BK_node_add(root, apply, -1); BK_geom_set_manager(apply, BK_GEOM_PACK);
BKContext ctx = BK_context_new(root); / input, focus, popups, undo / BKHost host = {0}; host.emit = on_event; / the window fills in the rest */ BK_context_set_host(ctx, &host);
if (BK_window_supported()) { /* Win32, X11 or Cocoa */ BKWindow *win = BK_window_new(ctx, “BUI from C”, 320, 120); BK_window_show(win); BK_window_run(); BK_window_free(win); } BK_context_free(ctx); BK_node_free(root); return 0; }
cmake -S . -B build -DBUI_BUILD_EXAMPLES=ON
cmake --build build --target bui_kit_hello

A bigger C program: a modifier stack (examples/site/kit_modifiers.c)
Without a window system, render into a raster instead
(BK_render(ctx, raster, w, h, full)), which is also how tests and
screenshots work. Guide: docs/c-api.md.
15. How it works
your code: tkinter Qt components Dear ImGui (C++/C/Python/Rust) Rust: rsx! / HTML / CSS / Tailwind / hooks JS / React
│ │ │ │ │ │
└──── Python: options, signals │ ImGui core + BUI backend └── style cascade + taffy layout ◄────┘
│ │ │
C kit (kit/): node tree · geometry · input & interaction · Blender widget drawing · undo · animation · themes · Blender search/expr
│
renderer: damage-driven software raster (parallel) or GPU (Direct3D 11 / OpenGL 3.3, instanced, opt-in)
│
window: native Win32 / X11 / Cocoa window · stdlib Tk window · headless (tests, screenshots)
- Your code, in any language above, creates widgets and says what happens when they change.
- The kit keeps them in one tree, lays them out and handles input, following Blender’s rules.
- The renderer draws them, on the CPU by default or on the GPU if you ask.
- Damage rendering keeps it cheap: a change redraws only the rectangle it touched, and an idle window uses no CPU at all.
What’s under the hood:
These rules live in the C kit, so they work the same everywhere Blender
widgets are drawn: the Python components, tkinter and Qt syntax, the Rust and
JavaScript Blender components and form controls inside styled, ImGui’s
Blender-widgets build, and every C kit widget.
Coming soon: typing values with units (“2 m”), Blender’s search-as-you-type popups, and widget drag and drop. More: Blender’s widgets.
In Rust and JavaScript you pick the look per element:
The components are Button, Checkbox, Radio, NumberField, NumberSlider,
TextField, TextArea, ColorSwatch, Dropdown and ProgressBar. Each one
is the HTML element it stands for, so every attribute, style and event works on
it:
rsx! {
import { render, NumberSlider, Button } from "@blender-ui/react"
// <NumberSlider min={0} max={10} onChange={...} />, <Button onClick={...}>Apply</Button>
// DOM API: win.createElement("NumberSlider")
cargo run --example forms: plain HTML, inside styled, and the Blender components


The same markup, plain (left) and inside styled (right). Plain HTML looks the same in both themes.

Blender components from Rust (site_components.rs)
Python’s Blender components (Panel, PieMenu, the node
editor …) are a separate, larger set.
BUI has two renderers, and they draw the same pixels.
The shaders evaluate the software raster’s formulas: the parity test finds 10 of 172,800 pixels that differ by more than 3/255, on both backends.
BUI_GPU=1 overrides the app-wide setting in code; BUI_GPU=0 turns the
app-wide defaults off, but a window that asks for the GPU itself still gets
it. Where no device can start, BUI quietly stays on the CPU
(BUI_GPU_DEBUG=1 says why).
Which one? A tool window, form or settings panel: the CPU (lightest on memory, idles at zero). A large or HiDPI window, lots of animation, thousands of items: the GPU (about half the CPU per frame, or less, for about 10 MB more RAM plus GPU memory). Servers and tests: the CPU. macOS: the CPU, for now (a GPU renderer there is coming soon).
Leave a BUI window open and walk away: it uses no CPU at all. Hover a button, and BUI redraws that button, not the window.
On the full component demo, that’s about 0.7 ms for a complete frame and about 0.05 ms for a hover or number-scrub frame. Animations run only while something moves, paced to the display. More: Damage rendering.
A window host puts a kit context in a top-level window and feeds it input.
BUI_UI_SCALE=1.5 fixes the UI scale instead of following the display (1 is
Blender’s default, 20 px widgets). More:
Window hosts.
Your app’s text looks the same on Windows, Linux and macOS, and it looks like Blender’s:
Limits worth knowing: no per-glyph font fallback yet (missing characters show as boxes), no IME, right-to-left text is reordered but not shaped, no OpenType features. Font fallback and IME are coming soon. More: Text and fonts.
BUI looks like Blender because it uses Blender’s theme. It ships two:
Blender’s Dark theme (the default) and its Light preset. Both are
generated by tools/gen_theme.py from Blender’s own Blender_Dark.xml and
Blender_Light.xml presets, over Blender 5.x’s built-in defaults. Switch at
run time, and every open window relayouts and redraws:
Widgets, panels, the region background, the styled HTML sheet and ImGui’s
Blender style all follow the theme. Plain HTML keeps a browser’s look either
way. Inside each theme you can still color things yourself: bg / fg in
tkinter, setStyleSheet in Qt syntax, color= on components, full CSS on
HTML in Rust and JavaScript, ImGui’s own style colors.
BUI also includes Blender’s icons: all 781 of Blender’s SVG icons, rasterized with Blender’s NanoSVG code so
they’re sharp at any scale. Use them by Blender’s name: Button("Add", icon="ADD"), EnumRow(..., icons=[...]).
Coming soon: loading any Blender theme file, beyond Dark and Light. More: Theming.
23. Python
pip install blenderui gives you four APIs in one package:
You can mix them in one process: windows, timers and the event loop are shared
(bui.host). Every interaction runs in C, so tests can drive widgets headless.
On the website: tkinter,
Qt syntax,
components,
headless testing.
The blenderui crate is a web-like framework drawn by BUI: every HTML element,
CSS, Tailwind, HTML-like markup (rsx! / view!) or gpui-style builders,
components and hooks. A taste:
rsx! { // Tailwind as attributes, any variant, arbitrary values; typos fail to compile <button px-3 py-1 rounded-md bg-zinc-800 hover:bg-sky-600 md:dark:hover:bg-sky-400 active:style=“transform: scale(0.97)” onClick={move || save()}> “Save”
// control flow right in the markup
- {for item in items {
- {item} }}
"Unsaved changes"
}}// real CSS, evaluated by the engine
error: rsx!: `bg-sky-50O` is not a Tailwind utility; did you mean `bg-sky-500` or `bg-sky-50` or `bg-sky-100`?
What’s in the box:
Not yet: async resources (use_resource), generic components, 3D
transforms, OpenType features, multi-column layout. Guide:
docs/rust.md, crate README:
bindings/rust/blenderui, and the website’s
Rust section (including
effects and animations).
- @blender-ui/react: a React 19.3 renderer. HTML host components, CSS and Tailwind, events, Suspense, transitions, actions, and the Blender components. Hooks keep React’s names but hold signals: pass one into JSX and a change updates that node without re-rendering. README: bindings/react.
- @blender-ui/svelte: Svelte 5 components (runes, snippets, bindings, keyed blocks, context, scoped

