If I invoke CenterOnScreen() before SetContent(), then I get a panic. Is it my misunderstanding of ui building or it's something else? Thanks.
Code:
func main() {
app := app.New()
circle := canvas.NewCircle(color.RGBA{
R: 255,
G: 0,
B: 255,
A: 20,
})
w := app.NewWindow("window name")
w.Resize(fyne.Size{640, 480})
w.CenterOnScreen()
w.SetContent(
circle,
)
w.ShowAndRun()
}
Error:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x57f019]
goroutine 1 [running, locked to thread]:
fyne.io/fyne/driver/gl.(*window).minSizeOnScreen(0xc00001a180, 0xc000085f10, 0x57f1f0)
C:/Dev/go/src/fyne.io/fyne/driver/gl/window.go:114 +0x39
fyne.io/fyne/driver/gl.(*window).CenterOnScreen(0xc00001a180)
C:/Dev/go/src/fyne.io/fyne/driver/gl/window.go:92 +0x36
main.main()
C:/Dev/go/src/sandbox/main.go:23 +0x124
The terminal process terminated with exit code: 2
specs:
Thanks for the bug report - this should clearly not happen. Is placing that call after SetContent an appropriate work around at this time?
I get the same issue, and placing that after SetContent doesn't crash anymore, but the window is not actually in the center of the screen.
env: MaxOS
Hello @andydotxyz!
Thanks for the bug report - this should clearly not happen. Is placing that call after SetContent an appropriate work around at this time?
Yes, it's. :)
P.S. I did a little research of available Go Gui libraries and It seems that Fyne is probably on of the best options at this moment. Looks promising. Thank you for the library.
hmmmmm I had tested this both ways initially, not sure what changed :anguished:
Did not test on mac os, just debian + kde .
Could you guys check against #220 ? It works as I expect it to on my system, hopefully now it works for everyone as expected :)
Hello @paulhovey!
I didn't work with go modules before and It was a bit confusing, but I have checked it (#220) out according to these instructions https://github.com/fyne-io/fyne/pull/153.
It works like a charm. Thank you. :)
This is now fixed but the develop branch is not yet merged to master.
The next time we promote the development branch this ticket will be marked as closed.