February 2019
Intermediate to advanced
450 pages
11h 59m
English
A basic hello world application with Go-GTK is similar to the previous one we looked at: we create a window, add a vertical box, and append a label and a button. The following code sample should be straightforward, but we'll look in more detail at some of the specifics:
package mainimport "github.com/mattn/go-gtk/gtk"func main() { gtk.Init(nil) window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL) window.SetTitle("Hello") quit := gtk.NewButton() quit.SetLabel("Quit") quit.Clicked(func() { gtk.MainQuit() }) vbox := gtk.NewVBox(false, 3) vbox.Add(gtk.NewLabel("Hello World!")) vbox.Add(quit) window.Add(vbox) window.SetBorderWidth(3) window.ShowAll() gtk.Main()}
Firstly, we import the github.com/mattn/go-gtk/gtk package for the main GTK namespace. ...
Read now
Unlock full access