forked from go/golangs_learn
VIVIMAN
3 years ago
4 changed files with 36 additions and 1 deletions
@ -0,0 +1,32 @@ |
|||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
"github.com/andlabs/ui" |
||||
|
_ "github.com/andlabs/ui/winmanifest" |
||||
|
) |
||||
|
|
||||
|
func main() { |
||||
|
err := ui.Main(func() { |
||||
|
name := ui.NewEntry() |
||||
|
button := ui.NewButton("Greet") |
||||
|
greeting := ui.NewLabel("") |
||||
|
box := ui.NewVerticalBox() |
||||
|
box.Append(ui.NewLabel("Enter your name:"), false) |
||||
|
box.Append(name, false) |
||||
|
box.Append(button, false) |
||||
|
box.Append(greeting, false) |
||||
|
window := ui.NewWindow("Hello", 200, 100, false) |
||||
|
window.SetChild(box) |
||||
|
button.OnClicked(func(*ui.Button) { |
||||
|
greeting.SetText("Hello, " + name.Text() + "!") |
||||
|
}) |
||||
|
window.OnClosing(func(*ui.Window) bool { |
||||
|
ui.Quit() |
||||
|
return true |
||||
|
}) |
||||
|
window.Show() |
||||
|
}) |
||||
|
if err != nil { |
||||
|
panic(err) |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue