Table – Fyne Golang GUI Tutorial 63
Table – Fyne Golang GUI Tutorial 63
Fyne Table is explained in this fyne golang example.
Fyne table is similar to fyne list. Except one thing that i.e. multiple rows and columns.
<div> <div>package main</div> <div>// import fyne</div> <div>import (</div> <div> "fmt"</div> <div> "fyne.io/fyne/v2"</div> <div> "fyne.io/fyne/v2/app"</div> <div> "fyne.io/fyne/v2/widget"</div> <div>)</div> <div>func main() {</div> <div> // New app</div> <div> a := app.New()</div> <div> // new title and window</div> <div> w := a.NewWindow("Table widget")</div> <div> // resize</div> <div> w.Resize(fyne.NewSize(400, 400))</div> <div> // create table widget</div> <div> // table is like list , just 2 values, instead of one</div> <div> table := widget.NewTable(</div> <div> // row and col . I want to create 3 row , 3 col</div> <div> func() (int, int) { return 3, 3 },</div> <div> // Now I want to specify widget. like label, checkbox</div> <div> func() fyne.CanvasObject { return widget.NewLabel("....") },</div> <div> // update/details data in widget</div> <div> func(i widget.TableCellID, obj fyne.CanvasObject) {</div> <div> // remember it is label and not newlabel</div> <div> // i is for index</div> <div> // i.col will set col value</div> <div> // i.row will present row value</div> <div> obj.(*widget.Label).SetText(fmt.Sprintf("%d %d", i.Col, i.Row))</div> <div> },</div> <div> )</div> <div> w.SetContent(table)</div> <div> w.ShowAndRun()</div> <div>}</div> </div>
[easy_media_download url=”http://blogvali.com/wp-content/uploads/fyne-golang-downloads/main56.go” text=”Download Code” color=”red_darker”]
Fyne Golang GUI Course
Improved fyne documentation for free with videos.
Fyne table is another addition in our fyne examples series.
fyne widgets explained with the help of videos.