CARDs – Fyne GUI Golang tutorial 18
Card Widget in Fyne
Want to stylize your UI. Card is your best choice.
Card has 3 main parts:
1. Title
2. Subtitle
3. content
[sourcecode lang=”go”]
// Card Widget
card := widget.NewCard(
"Here is My Title",
"Here is my SubTitle",
// here you can use any Widget
canvas.NewImageFromFile("c:/dice/dice1.jpg"),
)
[/sourcecode]
Last Step #
[sourcecode lang=”go”]
//Showing content
w.SetContent(card)
[/sourcecode]
[sourcecode lang=”go” autolinks=”false” classname=”myclass” collapse=”false” firstline=”1″ gutter=”true” highlight=”1-3,6,9″ htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false” title=”Source Code main.go”]
package main
// importing fyne
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/widget"
)
func main() {
// new app
a := app.New()
//New window
w := a.NewWindow("CARDS In Fyne")
// Resize
w.Resize(fyne.NewSize(400, 400))
// Card Widget
card := widget.NewCard(
"Here is My Title",
"Here is my SubTitle",
// here you can use any Widget
canvas.NewImageFromFile("c:/dice/dice1.jpg"),
)
//Showing content
w.SetContent(card)
w.ShowAndRun() //Show and Run App
}