Simple windowed application: Difference between revisions

→‎{{header|Go}}: Update for library API changes
m (added whitespace before the TOC, added a Task (bold) header, enumerated the contents of the window to be created.)
(→‎{{header|Go}}: Update for library API changes)
Line 832:
 
import (
"fmt"
"github.com/mattn/go-gtk/gtk"
)
 
func main() {
gtk.Init(nil)
window := gtk.WindowNewWindow(gtk.GTK_WINDOW_TOPLEVELWINDOW_TOPLEVEL)
window.SetTitle("Click me")
label := gtk.LabelNewLabel("There have been no clicks yet")
var clicks int
button := gtk.ButtonWithLabelNewButtonWithLabel("click me")
button.Clicked(func() {
clicks++
if clicks == 1 {
label.SetLabel("Button clicked 1 time")
} else {
label.SetLabel(fmt.Sprintf("Button clicked %d times",
clicks))
}
}
})
vbox := gtk.VBoxNewVBox(false, 1)
vbox.Add(label)
vbox.Add(button)
window.Add(vbox)
window.Connect("destroy", func() {
gtk.MainQuit()
})
window.ShowAll()
gtk.Main()
}</lang>
 
1,707

edits