site  contact  subhomenews

ui GUI toolkit for Nim

August 30, 2022 — BarryK

Starting to look at GUI toolkits for Nim. Lots to choose from:

https://github.com/nim-lang/Nim/wiki/Curated-Packages#gui

That isn't a complete list. I found more, some of them inactive projects.

Made a start, looked at 'ui':

https://github.com/nim-lang/ui

ui is a wrapper for 'libui', which started life as a GUI toolkit for the 'go' language (libui is a wrapper for gtk3):

https://github.com/andlabs/libui

Here is an example from the 'ui' project, 'controllgallery.nim':

img1

Now here is the great news; the binary executable, after stripping, is only 27KB. That is using 'libui.so.0', which is 187KB. Here is how I compiled 'controllgallery.nim':

# nim c -d:release --opt:size -d:useLibUiDll -d:useMalloc --mm:orc --passC:-flto --passL:-flto controllgallery

That "-d:useLibUiDll" tells nim to link with the shared libui.so, instead of static linking. The source code looks very simple:

https://github.com/nim-lang/ui/blob/master/examples/controllgallery.nim

Definitely a contender!    

Tags: easy