-
-
Notifications
You must be signed in to change notification settings - Fork 247
/
arrow.go
48 lines (36 loc) · 1.02 KB
/
arrow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"github.com/mattn/go-gtk/gtk"
"os"
)
func createArrowButton(at gtk.ArrowType, st gtk.ShadowType) *gtk.Button {
b := gtk.NewButton()
a := gtk.NewArrow(at, st)
b.Add(a)
b.Show()
a.Show()
return b
}
func main() {
gtk.Init(&os.Args)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.SetTitle("Arrow Buttons")
window.Connect("destroy", gtk.MainQuit)
box := gtk.NewHBox(false, 0)
box.Show()
window.Add(box)
up := createArrowButton(gtk.ARROW_UP, gtk.SHADOW_IN)
down := createArrowButton(gtk.ARROW_DOWN, gtk.SHADOW_OUT)
left := createArrowButton(gtk.ARROW_LEFT, gtk.SHADOW_ETCHED_IN)
right := createArrowButton(gtk.ARROW_RIGHT, gtk.SHADOW_ETCHED_OUT)
box.PackStart(up, false, false, 3)
box.PackStart(down, false, false, 3)
box.PackStart(left, false, false, 3)
box.PackStart(right, false, false, 3)
up.Clicked(func() { println("↑") })
down.Clicked(func() { println("↓") })
left.Clicked(func() { println("←") })
right.Clicked(func() { println("→") })
window.Show()
gtk.Main()
}