Chess Grid – Fyne Golang GUI tutorial 76

Chess Grid – Fyne Golang GUI tutorial 76


package main
// import fyne
import (
    "image/color"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/canvas"
    "fyne.io/fyne/v2/container"
)
func main() {
    // new app
    a := app.New()
    // new title setup
    w := a.NewWindow("my chess grid")
    // lets create a grid
    grid1 := container.NewGridWithColumns(33)
    // lets use for loop
    // nested loop, double loop,
    // lets add a child loop
    for i := 0; i < 33; i++ {
        for j := 0; j < 33; j++ {
            rect := canvas.NewRectangle(color.Gray{0x30})
            if i%2 == j%2 {
                rect.FillColor = color.Black
            }
            grid1.Add(rect)
        }
    }
    //setup content
    w.SetContent(grid1) // add grid
    w.ShowAndRun()
}

Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: