mirror of
https://github.com/vbatts/imgsrv.git
synced 2024-12-26 15:56:31 +00:00
adding the hello world gtk example
This commit is contained in:
parent
ae688c93a9
commit
b224170a82
1 changed files with 43 additions and 0 deletions
43
gimgsrv/main.go
Normal file
43
gimgsrv/main.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/ziutek/gdk"
|
||||||
|
"github.com/ziutek/gtk"
|
||||||
|
)
|
||||||
|
|
||||||
|
func cbDelete(w *gtk.Widget, ev *gdk.Event) bool {
|
||||||
|
fmt.Println("Delete")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func cbDestroy(w *gtk.Widget) {
|
||||||
|
fmt.Println("Destroy")
|
||||||
|
gtk.MainQuit()
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
w := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
|
||||||
|
w.Connect("delete-event", cbDelete, nil)
|
||||||
|
w.Connect("destroy", cbDestroy, nil)
|
||||||
|
w.SetBorderWidth(10)
|
||||||
|
w.Show()
|
||||||
|
|
||||||
|
a := A{"Hello World!\n"}
|
||||||
|
|
||||||
|
b := gtk.NewButtonWithLabel("Hello World")
|
||||||
|
b.Connect("clicked", (*A).Hello, &a)
|
||||||
|
b.ConnectNoi("clicked", (*gtk.Widget).Destroy, w.AsWidget())
|
||||||
|
w.Add(b.AsWidget())
|
||||||
|
b.Show()
|
||||||
|
|
||||||
|
gtk.Main()
|
||||||
|
}
|
||||||
|
|
||||||
|
type A struct {
|
||||||
|
s string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *A) Hello(w *gtk.Widget) {
|
||||||
|
fmt.Printf(a.s)
|
||||||
|
}
|
Loading…
Reference in a new issue