If you have some ideas, suggestions or generally would like to help, please submit a GitHub Issue and/or PR!
- Declarative syntax - think SwiftUI or React but in Go
- Component-based - split your UI into small, fully encapsulated components
- Powered by GTK3 - leverage a established, stable cross-platform widget toolkit that should work almost everywhere Go can be compiled on
The best way is to look at the examples. Use go run
to start them, i.e.:
$ go run ./examples/simple
// You need to init GTK before anything else
gtk.Init(nil)
// Declare the window
window := Window{
Title: "Hello go-gooey!",
// Hook the destroy signal to a callback
Destroy: func() {
gtk.MainQuit()
},
// Set the default size, otherwise the window will be as big as the initial contents
DefaultSize: &Size{Width: 400, Height: 200},
// Describe the window children components
Children: []Widgetable{
&Label{
Text: "π",
},
},
}
// Try opening the window
err := window.Open()
if err != nil {
log.Fatal("Unable to open window:", err)
}
// Start the GTK main loop
gtk.Main()
It should look like this:
If you wish to bind a component attribute to a variable, you need to use a Property
type. It's practically a wrapper around RxGo
observable that allows to subscribe to changes:
// Define a StringProperty
counter := NewStringProperty()
window := Window{
// ...
Children: []Widgetable{
&Box{
Children: []Widgetable{
&Label{
// Assign the property to Text
Text: *counter,
},
&Button{
Label: "Hello!",
Clicked: func() {
// Modify the property value
counter.Set(counter.Value + " π")
},
},
},
},
},
}
The value changes, immediatelly triger an update on the component:
To make the debugging easier, you can use the GTK Inspector to peek inside of the running app.
- Logo composed from icons by Hugo Arganda, Alex Muravev and Ben Davis.