summaryrefslogtreecommitdiff
path: root/prev/examples/basicwindow
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-12-11 20:37:59 -0500
committerPietro Gagliardi <[email protected]>2015-12-11 20:37:59 -0500
commitf8e3f12ab02b528f2a05a4f713d7af7ea8e44b42 (patch)
tree82dedf4d37f0f6d31e88ebb2ca1ce6499dead261 /prev/examples/basicwindow
parente34c561ed5bedeb180437ec165882b98d70d38c1 (diff)
LET'S GET THIS FINAL REWRITE EVER STARTED
Diffstat (limited to 'prev/examples/basicwindow')
-rw-r--r--prev/examples/basicwindow/basicwindow.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/prev/examples/basicwindow/basicwindow.go b/prev/examples/basicwindow/basicwindow.go
new file mode 100644
index 0000000..c0259f5
--- /dev/null
+++ b/prev/examples/basicwindow/basicwindow.go
@@ -0,0 +1,37 @@
+package main
+
+import (
+ "github.com/andlabs/ui"
+ "log"
+)
+
+func main() {
+ // This runs the code that displays our GUI.
+ // All code that interfaces with package ui (except event handlers) must be run from within a ui.Do() call.
+ go ui.Do(gui)
+
+ err := ui.Go()
+ if err != nil {
+ log.Print(err)
+ }
+}
+
+func gui() {
+ // All windows must have a control inside.
+ // ui.Space() creates a control that is just a blank space for us to use.
+ newControl := ui.Space()
+
+ // Then we create a window.
+ w := ui.NewWindow("Window", 280, 350, newControl)
+
+ // We tell package ui to destroy our window and shut down cleanly when the user closes the window by clicking the X button in the titlebar.
+ w.OnClosing(func() bool {
+ // This informs package ui to shut down cleanly when it can.
+ ui.Stop()
+ // And this informs package ui that we want to hide AND destroy the window.
+ return true
+ })
+
+ // And finally, we need to show the window.
+ w.Show()
+}