I'm making an application with Fyne.
I need to create a grid where the left column will be fixed and the right column will stretch. In general, there will be a menu on the left, and the main block on the right (a screenshot of the expected one below).
I read the documentation https://developer.fyne.io/container/grid but still don't understand how to do it. Help me please.
Grid
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
)
func main() {
application := app.New()
window := application.NewWindow("title")
window.Resize(fyne.NewSize(1920, 1080))
window.ShowAndRun()
}
you can check the demo application of Fyne.
$ go get fyne.io/fyne/v2/cmd/fyne_demo
$ fyne_demo
from your description here is an example with menu on the left, and the main block on the right:
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Fyne Demo")
w.SetMaster()
content := container.NewMax()
title := widget.NewLabel("Component name")
intro := widget.NewLabel("An introduction would probably go\nhere, as well as a")
intro.Wrapping = fyne.TextWrapWord
tutorial := container.NewBorder(
container.NewVBox(title, widget.NewSeparator(), intro), nil, nil, nil, content)
split := container.NewHSplit(makeNav(), tutorial)
split.Offset = 0
w.SetContent(split)
w.Resize(fyne.NewSize(640, 460))
w.ShowAndRun()
}
func makeNav() fyne.CanvasObject {
tree := widget.NewTreeWithStrings(menuItems)
return container.NewBorder(nil, nil, nil, nil, tree)
}
var menuItems = map[string][]string{
"": {"welcome", "collections", "advanced"},
"collections": {"list", "table"},
}
output :
if you explore their demo on your go path source you can see the full function of (makeNav) that will make things clickable.
and to make (the left column will be fixed and the right column will stretch):
split.Offset = 0