Error in setting up my Fyne container, not initialized or declared properly

46 Views Asked by At

I am trying to initialize a container for my Fyne GUI,

I declared it globally here:

var w fyne.Window
var content *fyne.Container

Then I initialized it in main()

func main() {
 a := app.New()
w = a.NewWindow("Recursive Noise")

zoomIn := widget.NewButton("+", func() { zoomIn() })
//fmt.Println("print button", zoomIn)

zoomOut := widget.NewButton("-", func() { zoomOut() })
//log.Println("tapped")

content = container.NewBorder(nil, nil, zoomOut, zoomIn, thisImage)

w.SetContent(content)

however, I got the following error

panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x0 pc=0x7ff7d9952c4c]

I also tried

content = container.NewBorder(nil, nil, zoomOut, zoomIn, thisImage)
    
0

There are 0 best solutions below