mirror of
https://github.com/vbatts/imgsrv.git
synced 2024-12-26 15:56:31 +00:00
fiddling with the buttons. i'm new to gui things...
This commit is contained in:
parent
b224170a82
commit
cdd487f86a
1 changed files with 11 additions and 5 deletions
|
@ -6,8 +6,10 @@ import (
|
||||||
"github.com/ziutek/gtk"
|
"github.com/ziutek/gtk"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// this happens when the X is clicked (to close the app)
|
||||||
func cbDelete(w *gtk.Widget, ev *gdk.Event) bool {
|
func cbDelete(w *gtk.Widget, ev *gdk.Event) bool {
|
||||||
fmt.Println("Delete")
|
fmt.Println("Delete")
|
||||||
|
defer gtk.MainQuit()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +25,14 @@ func main() {
|
||||||
w.SetBorderWidth(10)
|
w.SetBorderWidth(10)
|
||||||
w.Show()
|
w.Show()
|
||||||
|
|
||||||
a := A{"Hello World!\n"}
|
f := gtk.NewFileChooserButton("Select File", gtk.FILE_CHOOSER_ACTION_OPEN)
|
||||||
|
w.Add(f.AsWidget())
|
||||||
|
f.Show()
|
||||||
|
|
||||||
b := gtk.NewButtonWithLabel("Hello World")
|
a := Action{"Hello World!\n"}
|
||||||
b.Connect("clicked", (*A).Hello, &a)
|
|
||||||
|
b := gtk.NewButtonWithLabel("Quit")
|
||||||
|
b.Connect("clicked", (*Action).Quit, &a)
|
||||||
b.ConnectNoi("clicked", (*gtk.Widget).Destroy, w.AsWidget())
|
b.ConnectNoi("clicked", (*gtk.Widget).Destroy, w.AsWidget())
|
||||||
w.Add(b.AsWidget())
|
w.Add(b.AsWidget())
|
||||||
b.Show()
|
b.Show()
|
||||||
|
@ -34,10 +40,10 @@ func main() {
|
||||||
gtk.Main()
|
gtk.Main()
|
||||||
}
|
}
|
||||||
|
|
||||||
type A struct {
|
type Action struct {
|
||||||
s string
|
s string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *A) Hello(w *gtk.Widget) {
|
func (a *Action) Quit(w *gtk.Widget) {
|
||||||
fmt.Printf(a.s)
|
fmt.Printf(a.s)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue