Fyne: How do I set the size and position of the window?

Created on 10 Jun 2019  Â·  9Comments  Â·  Source: fyne-io/fyne

I want to set the size and position of the window.
Either it can't be found or it doesn't work.

All 9 comments

To set the size use Window.Resize().
There is currently no support for setting window position (it is not possible to support that on all platforms so we don’t include it).

@andydotxyz
Window.Resize () has failed.
Maybe I wrote the wrong code. Can you give me an example?

myWin.Resize(fyne.NewSize(200, 300)) should be all you need.
If this is not working can you provide some more information?

Sometimes the size of the generated window is successful, and sometimes what is the failure?
image

OS:Windows 10 v1903
Go version:go1.12.5 windows/amd64
GCC version:6.2.0

Ah, thank you. There is a known bug that means sometimes the window does not use the size requested. We are fixing it and will have the resolution public in the release next week.

Can the author get help from this code?

package main

import (
    "github.com/lxn/walk"
)

func main() {
    window, _ := walk.NewMainWindow()
    window.SetWidth(400)
    window.SetHeight(200)

    // Set position
    window.SetX(500)
    window.SetY(500)

    window.Show()
    window.Run()
}

Thanks but we do not use the walk backend. It's GLFW but the resize issues are partly due to internal Fyne code that we are working on right now for 1.1 release.

@andydotxyz I don't want all the platforms to support this feature, just macOS and windows10 are ok for me now.
So I need to export the github.com/go-gl/glfw/v3.2/glfw.Window, then GetPos and SetPos can be used by fyne.Window.
Now it works, I think it is not so ideal, but I don't have time to wait for your official release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jacalz picture Jacalz  Â·  4Comments

boussou picture boussou  Â·  9Comments

andydotxyz picture andydotxyz  Â·  3Comments

Nigh picture Nigh  Â·  5Comments

MarkRosemaker picture MarkRosemaker  Â·  5Comments