UI Builder for @nim-lang/ui using Glade
Checkout examples
you must have Glade installed in order to build UI and create *.glade files
$ nimble install uibuilder
UIBuilder contains a library for load glade file and construct UI on-the-fly, another part - uibuilder
binary - which generates a Nim module from glade file.
This method is prefered:
- Glade file compiled into AST at compile-time
- No more glade files in your distribution package
- Output module wont depends on UIBuilder
- Binary size reduced 50%
import ui, ospaths, uibuilderpkg/codegen
const path = joinPath(staticExec("pwd"), "test.glade")
init()
build(path)
mainLoop()
import ui, uibuilder
var builder = newBuilder()
builder.load("ui.glade")
builder.run()
the
uibuilder
command will generates a Nim module which can run standalone or importable. the generated module will not requiresuibuilder
, it just needui
moduleNote: only widgets have
id
are exported
$ uibuilder examples/basic_controls.glade
Nim code saved at: examples/basic_controls.nim
Run command bellow to see the result:
# nim c -r examples/basic_controls.nim
Almost widgets are same as GTK Widgets, but there are some widgets need a small hack in order to work
UI Builder converts GtkFrame
into a Group
, it will finds nested GtkLabel
and make it as Group
's title
In Glade, you must cover a group of GtkRadioButton
s with a GtkBox
, the box must have a style class named radiobuttons
Tab
uses GtkNotebook
, tab's container must be a GtkBox
Just add a GtkTextView
widget to make a MultilineEntry
, you also can pre-define text for it w/ GtkTextBuffer
libui requires to init Menu
first, before creating main Window
, so it better make a GtkMenuBar
separated
Slider
uses GtkScale
You can defined ajustment for Slider
and SpinBox
with GtkAdjustment
- Better event handling
- Code generator for static layout
- Support QT Designer layout file