horizontal & vertical scroll example – Fyne GUI Golang tutorial 43
horizontal scroll vertical scroll – Fyne GUI Golang tutorial 43
Are you looking for fyne scroll example tutorial ? Here is example/tutorial with soruce code.
In this tutorial , We are going to discuss horizonal and vertical scroll in fyne.
Very simple and easy to use fyne golang example.
Fyne Vertical scroll
You need to import container and then use NewVScroll for vertical scrolling.
c := container.NewVScroll( // your widgets goes here )
For more than one element you need to use NewHBox or NewVBox container.
container.NewHBox( // New Horizontal Box red, // for red Rectangle blue, // for blue Rectangle ),
Fyne Horizontal scroll
You need to import container and then use NewHScroll for horizontal scrolling.
c := container.NewHScroll( // your widgets goes here )
For more than one element you need to use NewHBox or NewVBox container.
container.NewVBox( // New Horizontal Box red, // for red Rectangle blue, // for blue Rectangle ),
How to change fyne scroll direction
Change scroll direction
c.Direction = container.ScrollHorizontalOnly
package main // import fyne import ( "image/color" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" ) func main() { // New app a := app.New() // new windown and title w := a.NewWindow("Scroll") // resize w.Resize(fyne.NewSize(400, 400)) // red rectangle red := canvas.NewRectangle( color.NRGBA{R: 255, G: 0, B: 0, A: 255}) red.SetMinSize(fyne.NewSize(400, 400)) // blue rectangle blue := canvas.NewRectangle( color.NRGBA{R: 0, G: 0, B: 255, A: 255}) blue.SetMinSize(fyne.NewSize(400, 400)) // New Scroll & Vbox c := container.NewVScroll( container.NewHBox( // New Horizontal Box red, blue, ), ) // Change scroll direction c.Direction = container.ScrollHorizontalOnly // setup content w.SetContent(c) // show and run w.ShowAndRun() }
[easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main41.go” text=”Download Code” color=”red_darker”]
Fyne Golang GUI Course