No description
Find a file
2019-07-24 21:50:25 +07:00
.github Create FUNDING.yml 2019-07-24 21:50:25 +07:00
examples get rid of isNil 2018-09-11 22:41:10 +07:00
tests put generated code in to a proc 2018-08-17 02:41:26 +07:00
uibuilderpkg get rid of isNil 2018-09-11 22:41:10 +07:00
.gitignore Initial commit 2017-06-13 21:23:51 +07:00
LICENSE Initial commit 2017-06-13 21:23:51 +07:00
nim.cfg get rid of isNil 2018-09-11 22:41:10 +07:00
README.md add nimblegui to showcases 2018-08-17 15:48:47 +07:00
uibuilder.nim get rid of isNil 2018-09-11 22:41:10 +07:00
uibuilder.nimble version bump 2018-08-17 15:31:58 +07:00

uibuilder.nim

UI Builder for @nim-lang/ui using Glade

Checkout examples

Usage

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.

Construct UI at compile-time

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()

Load Glade on run-ime file

import ui, uibuilder

var builder = newBuilder()
builder.load("ui.glade")
builder.run()

Generate Nim module (WIP)

the uibuilder command will generates a Nim module which can run standalone or importable. the generated module will not requires uibuilder, it just need ui module

Note: 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

Showcases:

Widgets

Almost widgets are same as GTK Widgets, but there are some widgets need a small hack in order to work

Group

UI Builder converts GtkFrame into a Group, it will finds nested GtkLabel and make it as Group's title

RadioButtons

In Glade, you must cover a group of GtkRadioButtons with a GtkBox, the box must have a style class named radiobuttons

Tab

Tab uses GtkNotebook, tab's container must be a GtkBox

MultilineEntry

Just add a GtkTextView widget to make a MultilineEntry, you also can pre-define text for it w/ GtkTextBuffer

Menu

libui requires to init Menu first, before creating main Window, so it better make a GtkMenuBar separated

Slider

Slider uses GtkScale You can defined ajustment for Slider and SpinBox with GtkAdjustment

examples

Todos

  • Better event handling
  • Code generator for static layout
  • Support QT Designer layout file