Created
September 23, 2014 03:04
-
-
Save copiesofcopies/41fb8ff7942eb3ad5244 to your computer and use it in GitHub Desktop.
Minimal broken Go ui program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/andlabs/ui" | |
) | |
func mainWindow() { | |
w2_button := ui.NewButton("Open Window 2") | |
// Open window 2 | |
w2_button.OnClicked(func() { | |
go newWindow() | |
}) | |
main_interface := ui.NewVerticalStack( | |
w2_button) | |
main_w := ui.NewWindow("Window 1", 200, 200, main_interface) | |
main_w.OnClosing(func() bool { | |
ui.Stop() | |
return true | |
}) | |
main_w.Show() | |
} | |
func newWindow() { | |
ok_button := ui.NewButton("OK") | |
w2_interface := ui.NewVerticalStack( | |
ok_button) | |
w2 := ui.NewWindow("Window 2", 200, 200, w2_interface) | |
// Close Window 2 | |
ok_button.OnClicked(func() { | |
w2.Hide() | |
}) | |
w2.Show() | |
} | |
func main() { | |
go ui.Do(mainWindow) | |
err := ui.Go() | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment