Skip to content
/ go-gooey Public

πŸ₯ž Declarative GUI framework for Go using GTK3. Think Go + SwiftUI + GTK

License

Notifications You must be signed in to change notification settings

suda/go-gooey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

gooey

Declarative UI framework for Go




🚨 This project is in its beginning and any APIs are subject to change without a notice 🚨

If you have some ideas, suggestions or generally would like to help, please submit a GitHub Issue and/or PR!

🌈 Features

  • 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

πŸ“™ Usage

The best way is to look at the examples. Use go run to start them, i.e.:

$ go run ./examples/simple

Basic example

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

Properties

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:

πŸ” GTK Inspector

To make the debugging easier, you can use the GTK Inspector to peek inside of the running app.

Attributions

  • Logo composed from icons by Hugo Arganda, Alex Muravev and Ben Davis.

About

πŸ₯ž Declarative GUI framework for Go using GTK3. Think Go + SwiftUI + GTK

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published