IUPforZig
IUP (Portable User Interface Toolkit) bindings for the Zig language.
Install / Use
/learn @batiati/IUPforZigREADME
IUP for Zig
A Zig language idiomatic and type-checked bindings for IUP Portable User Interface Toolkit
Examples


First look
A simple hello world example looks like this:
const iup = @import("iup.zig");
pub fn main() !void {
try iup.MainLoop.open();
defer iup.MainLoop.close();
var main_dialog = try (iup.Dialog.init()
.setTitle("Hello World")
.setChildren(
.{
iup.VBox.init()
.setMargin(10, 10)
.setGap(10)
.setAlignment(.ACenter)
.setChildren(
.{
iup.Label.init()
.setTitle("Hello World from IUPforZig"),
iup.Button.init()
.setTitle("OK")
.setActionCallback(exit),
},
),
},
).unwrap());
defer main_dialog.deinit();
try main_dialog.showXY(.Center, .Center);
try iup.MainLoop.beginLoop();
}
fn exit(button: *iup.Button) !void {
iup.MainLoop.exitLoop();
}
Resulting in this:


IUP Metadata
This project contains source-code automatically generated by The IUP Metadata Project.
Most of the hard/repetitive work was done by code-gen tool, however, the API guidelines and all the interop code belongs here on this project.
API
Zig does not require any special treatment to use C libraries, so to use IUP in Zig, it is as simple as adding @cInclude("iup.h") in your source code, no need for special bindings!
This project attempts to create Zig bindings for IUP Toolkit with idiomatic and type-checked API, where none of the original IUP's declarations are exposed in the public interface, only names and concepts are kept as close as possible.
Comparison:
- IUP simple example in C:
#include <stdlib.h>
#include <iup.h>
int main(int argc, char **argv)
{
Ihandle *dlg, *multitext, *vbox;
IupOpen(&argc, &argv);
multitext = IupText(NULL);
vbox = IupVbox(
multitext,
NULL);
IupSetAttribute(multitext, "MULTILINE", "YES");
IupSetAttribute(multitext, "EXPAND", "YES");
dlg = IupDialog(vbox);
IupSetAttribute(dlg, "TITLE", "Simple Notepad");
IupSetAttribute(dlg, "SIZE", "QUARTERxQUARTER");
IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
IupSetAttribute(dlg, "USERSIZE", NULL);
IupMainLoop();
IupClose();
return EXIT_SUCCESS;
}
- Equivalent example in Zig:
const iup = @import("iup.zig");
pub fn main() !void {
try iup.MainLoop.open();
defer iup.MainLoop.close();
var main_dialog = try (iup.Dialog.init()
.setTitle("Simple Notepad")
.setSize(.Quarter, .Quarter)
.setChildren(
.{
iup.VBox.init()
.setChildren(
.{
iup.Text.init()
.setMultiline(true)
.setExpand(.Yes),
},
),
},
).unwrap());
defer main_dialog.deinit();
try main_dialog.showXY(.Center, .Center);
try iup.MainLoop.beginLoop();
}
How to build
-
Download Zig;
-
Install IUP shared libraries and run:
NOTE: curl is needed to download IUP binaries.
Linux
./install_iup.sh
zig build run
Windows
.\install_iup.bat
zig build run
For more information, please visit IUP's download page for your platform: https://sourceforge.net/projects/iup/files/3.30/
Dependencies for
libimandlibcdmay be required: https://sourceforge.net/projects/imtoolkit/files/3.15/ https://sourceforge.net/projects/canvasdraw/files/5.14/
Pending work
-
[X] Support for collections and indexed attributes (list items for example)
-
[ ] Complete the Simple Notepad example.
-
[X] Support Linux and Windows (using shared libs)
-
[ ] Investigate how to build IUP from C sources in Zig.
-
[ ] More tests, and sanitize failing tests.
-
[ ] Additional controls (image library, matrix, GLCanvas, scintilla, plot, etc)
Feel free to place any comments/issues/PRs, it will be very nice to receive any feedback 🚀.
Prior Art
Some great projects that served as inspiration.
License
-
This project is a free and unencumbered software released into the public domain. Plese visit unlicense.org for more details.
-
IUP is a Tecgraf/PUC-Rio project licensed under the terms of the MIT license. Please visit https://www.tecgraf.puc-rio.br/iup/ for more details.
Related Skills
node-connect
339.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.8kCommit, push, and open a PR
