-
Notifications
You must be signed in to change notification settings - Fork 0
/
colorbutton.go
49 lines (39 loc) · 911 Bytes
/
colorbutton.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
49
// github.com/gotk3/gotk3/blob/master/gtk/gtk.go
package main
import (
"github.com/gotk3/gotk3/gtk"
"log"
)
func main() {
// Initialize gtk
gtk.Init(nil)
// Create new window
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
panic(err)
}
// Set the title of the window
win.SetTitle("gtk.ColorButton Example")
// Quit gtk when the window is closed
win.Connect("destroy", func(){
log.Println("Main window being destroyed")
gtk.MainQuit()
})
// Create a new ColorButton object
colorbutton, err := gtk.ColorButtonNew()
if err != nil {
panic(err)
}
colorbutton.Connect("color-set", func(){
// When the user selects a color
color := colorbutton.GetRGBA()
log.Println("Added color:", color)
// Quit the program
//gtk.MainQuit()
})
// Add the ColorButton to the window and show it
win.Add(colorbutton)
win.ShowAll()
// Run the main gtk loop
gtk.Main()
}