Gallery

Hello, declarative

The smallest app in ImmyGo's declarative ui package: text, a button and a counter, with no Gio imports.

Hello, declarative: a still of the demo

Run it on your machine:

go run github.com/amken3d/immygo/examples/ui-hello@latest

Source

ui-hello/hello/hello.go
// Package hello is the ui-hello example's app, as a package so that
// other programs (the immygo.app demo bundle) can run it. main.go runs it.
package hello
import (
"fmt"
"github.com/amken3d/immygo/ui"
)
// Main runs the example. It blocks until the window closes.
func Main() {
count := ui.NewState(0)
ui.Run("Hello ImmyGo", func() ui.View {
return ui.Centered(
ui.VStack(
ui.Text("Hello, ImmyGo!").Headline(),
ui.Text("Build beautiful Go UIs with ease."),
ui.Divider(),
ui.Button("Click Me!").OnClick(func() {
count.Update(func(n int) int { return n + 1 })
fmt.Printf("Clicked %d times\n", count.Get())
}),
ui.Text(fmt.Sprintf("Clicks: %d", count.Get())).Caption(),
ui.Progress(float32(count.Get()%11)/10.0),
).Spacing(16).Center(),
)
}, ui.Size(600, 400))
}