Simple windowed application: Difference between revisions
Content added Content deleted
(added Unicon example) |
(Go solution) |
||
Line 606: | Line 606: | ||
script? [IF] main [THEN] |
script? [IF] main [THEN] |
||
previous previous previous</lang> |
previous previous previous</lang> |
||
=={{header|Go}}== |
|||
{{libheader|go-gtk}} |
|||
<lang go>package main |
|||
import ( |
|||
"fmt" |
|||
"gtk" |
|||
) |
|||
func main() { |
|||
gtk.Init(nil) |
|||
window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL) |
|||
window.SetTitle("Click me") |
|||
label := gtk.Label("There have been no clicks yet") |
|||
var clicks int |
|||
button := gtk.ButtonWithLabel("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.VBox(false, 1) |
|||
vbox.Add(label) |
|||
vbox.Add(button) |
|||
window.Add(vbox) |
|||
window.Connect("destroy", func(*gtk.CallbackContext) { |
|||
gtk.MainQuit() |
|||
}, |
|||
"") |
|||
window.ShowAll() |
|||
gtk.Main() |
|||
}</lang> |
|||
=={{header|Groovy}}== |
=={{header|Groovy}}== |