MCPcopy Index your code
hub / github.com/andlabs/ui

github.com/andlabs/ui @main sqlite

repository ↗ · DeepWiki ↗
389 symbols 766 edges 43 files 298 documented · 77%
README

ui: platform-native GUI library for Go

This is a library that aims to provide simple GUI software development in Go. It is based on my libui, a simple cross-platform library that does the same thing, but written in C.

It runs on/requires:

  • Windows: cgo, Windows Vista SP2 with Platform Update and newer
  • Mac OS X: cgo, Mac OS X 10.8 and newer
  • other Unixes: cgo, GTK+ 3.10 and newer
    • Debian, Ubuntu, etc.: sudo apt-get install libgtk-3-dev
    • Red Hat/Fedora, etc.: sudo dnf install gtk3-devel

It also requires Go 1.8 or newer.

It currently aligns to libui's Alpha 4.1, with only a small handful of functions not available.

Status

Package ui is currently mid-alpha software. Much of what is currently present runs stabily enough for the examples and perhaps some small programs to work, but the stability is still a work-in-progress, much of what is already there is not feature-complete, some of it will be buggy on certain platforms, and there's a lot of stuff missing. The libui README has more information.

Installation

Once you have the dependencies installed, a simple

go get github.com/andlabs/ui/...

should suffice.

Documentation

The in-code documentation is sufficient to get started, but needs improvement.

Some simple example programs are in the examples directory. You can go build each of them individually.

Windows manifests

Package ui requires a manifest that specifies Common Controls v6 to run on Windows. It should at least also state as supported Windows Vista and Windows 7, though to avoid surprises with other packages (or with Go itself; see this issue) you should state compatibility with higher versions of Windows too.

The simplest option is provided as a subpackage winmanifest; you can simply import it without a name, and it'll set things up properly:

import _ "github.com/andlabs/ui/winmanifest"

You do not have to worry about importing this in non-Windows-only files; it does nothing on non-Windows platforms.

If you wish to use your own manifest instead, you can use the one in winmanifest as a template to see what's required and how. You'll need to specify the template in a .rc file and use windres in MinGW-w64 to generate a .syso file as follows:

windres -i resources.rc -o winmanifest_windows_GOARCH.syso -O coff

You may also be interested in the github.com/akavel/rsrc and github.com/josephspurrier/goversioninfo packages, which provide other Go-like options for embedding the manifest.

Note that if you choose to ship a manifest as a separate .exe.manifest file instead of embedding it in your binary, and you use Cygwin or MSYS2 as the source of your MinGW-w64, Cygwin and MSYS2 instruct gcc to embed a default manifest of its own if none is specified. This default will override your manifest file! See this issue for more details, including workaround instructions.

macOS program execution

If you run a macOS program binary directly from the command line, it will start in the background. This is intentional; see this for more details.

Extension points exported contracts — how you extend this code

TableValue (Interface)
TableValue is a type that represents a piece of data that can come out of a TableModel. [11 implementers]
tablemodel.go
Attribute (Interface)
Attribute stores information about an attribute in an AttributedString. The following types can be used as Attributes: [11 …
drawtext.go
AreaHandler (Interface)
AreaHandler defines the functionality needed for handling events from an Area. Each of the methods on AreaHandler is cal [1 …
areahandler.go
Control (Interface)
Control represents a GUI control. It provdes methods common to all Controls. The preferred way to create new Controls i [1 …
control.go
TableModelHandler (Interface)
TableModelHandler defines the methods that TableModel calls when it needs data. [1 implementers]
tablemodel.go

Core symbols most depended-on inside this repo

Append
called by 44
box.go
freestr
called by 36
util.go
NewControlBase
called by 26
control.go
frombool
called by 21
util.go
ControlFromLibui
called by 18
control.go
AppendUnattributed
called by 17
drawtext.go
SetPadded
called by 16
box.go
tobool
called by 16
util.go

Shape

Method 201
Function 114
Struct 49
TypeAlias 20
Interface 5

Languages

Go100%

Modules by API surface

drawtext.go45 symbols
draw.go43 symbols
tablemodel.go27 symbols
control.go24 symbols
areahandler.go19 symbols
table.go13 symbols
examples/histogram.go13 symbols
window.go12 symbols
multilineentry.go11 symbols
entry.go11 symbols
examples/drawtext.go10 symbols
tab.go9 symbols

For agents

$ claude mcp add ui \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact