func renderPreview(filename string) { data, err := Probe(filename) if err != nil { panic(err) } d := data.Format.Duration() const PreviewSize = 128 canvas := image.NewRGBA(image.Rect(0, 0, int(PreviewSize*d/time.Second), PreviewSize)) for x := canvas.Bounds().Min.X; x < canvas.Bounds().Max.X; { img, err := Frame(filename, time.Duration(x)*time.Second/PreviewSize, "-vf", fmt.Sprintf("scale=-1:%d", PreviewSize)) if err != nil { break } draw.Draw(canvas, img.Bounds().Add(image.Point{x, 0}), img, image.ZP, draw.Src) x += img.Bounds().Dx() } go ui.Do(func() { showPreview(canvas) }) }
func main() { go ui.Do(initGUI) err := ui.Go() if err != nil { panic(err) } }
func main() { go ui.Do(func() { name := ui.NewTextField() button := ui.NewButton("greet") greeting := ui.NewLabel("") stack := ui.NewVerticalStack( ui.NewLabel("name:"), name, button, greeting) window = ui.NewWindow("hello world", 200, 100, stack) button.OnClicked(func() { greeting.SetText("hello, " + name.Text() + "!") }) window.OnClosing(func() bool { ui.Stop() return true }) window.Show() }) err := ui.Go() if err != nil { panic(err) } }
func main() { go ui.Do(gui) err := ui.Go() if err != nil { log.Print(err) } }
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 main() { var err error current, err = fetchLatest() if err != nil { log.Fatalf("Error : %v\n", err) } go ui.Do(initGui) err = ui.Go() if err != nil { log.Fatalf("Error : %v\n", err) } }
func main() { if len(os.Args) != 1 { t := getJSON(getWords()) fmt.Println(simple(t)) } else { go ui.Do(gui) err := ui.Go() if err != nil { panic(err) } } }
func main() { simulation.Init() timer_10ms := time.Tick(10 * time.Millisecond) go ui.Do(func() { widthFloat := float64(inWidth * dpi) heightFloat := float64(inHeight * dpi) width := int(widthFloat) height := int(heightFloat) // Give ourselves a drawable canvas: canvas := &canvasArea{ img: image.NewRGBA(image.Rect(0, 0, width, height)), } area := ui.NewArea(width, height, canvas) w := ui.NewWindow("e-minor v2", width+8*2, height+28*2, area) w.SetMargined(false) w.OnClosing(func() bool { ui.Stop() return true }) w.Show() // This *should* be in the main UI message loop, but the 'ui' package does not expose the message loop. go func() { for { select { case <-timer_10ms: simulation.Timer_10msec() default: simulation.Handle() } } }() }) err := ui.Go() if err != nil { panic(err) } }
func main() { go ui.Do(func() { textview := ui.NewTextbox() textview.SetText("asd") window = ui.NewWindow("Hello", 300, 300, textview) window.OnClosing(func() bool { ui.Stop() return true }) window.Show() }) go startListen() err := ui.Go() if err != nil { panic(err) } }