fyne
fyne copied to clipboard
widget.Table does not fully show data when first rendered
Checklist
- [X] I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
- [X] This issue only relates to a single bug. I will open new issues for any other problems.
Describe the bug
I have a container and a table, separated by a HSplit, all housed in the center of a border layout. Yes, that seems convoluted, but this is a trimmed-down-to-the-essentials example. When the application is run, only part of the table gets data populated, not all of it. Clicking in the table causes the rest of the data to appear.
How to reproduce
- Run the code below
- Notice that the table is only partially populated
- Click in the table and watch the rest of the data appear
Screenshots
Just after app displays
Click on table
Example code
package main
import (
"fmt"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/widget"
)
type transaction struct {
Name string
Amount float64
Date time.Time
Memo string
}
func main() {
numTrans := 500
transactions := make([]transaction, numTrans)
for i := 0; i < numTrans; i++ {
transactions[i] = transaction{Name: fmt.Sprintf("name %3d", i), Memo: fmt.Sprintf("memo %3d", i), Amount: 123, Date: time.Now()}
}
var bindings []binding.DataMap
for i := range transactions {
bindings = append(bindings, binding.BindStruct(&transactions[i]))
}
table := widget.NewTable(
func() (int, int) {
return len(transactions), 4
},
func() fyne.CanvasObject {
return widget.NewLabel("wide content")
},
func(i widget.TableCellID, o fyne.CanvasObject) {
switch i.Col {
case 0:
o.(*widget.Label).SetText(transactions[i.Row].Name)
case 1:
o.(*widget.Label).SetText(transactions[i.Row].Date.Format("2006-01-02"))
case 2:
o.(*widget.Label).SetText(fmt.Sprintf("%.2f", transactions[i.Row].Amount))
case 3:
o.(*widget.Label).SetText(transactions[i.Row].Memo)
}
},
)
a := app.New()
w := a.NewWindow("Bug Test")
w.Resize(fyne.NewSize(600, 400))
sidebar := container.NewVBox(widget.NewLabel("side"), widget.NewLabel("bar"))
center := container.NewHSplit(sidebar, table)
content := container.NewBorder(
nil,
nil,
nil,
nil,
center,
)
w.SetContent(content)
w.ShowAndRun()
}
Fyne version
fyne.io/fyne/v2 v2.2.3
Go compiler version
go version go1.18.4 darwin/amd64
Operating system
macOS
Operating system version
Monterey 12.5
Additional Information
No response
I wonder if this is a duplicate of #3034 somehow. Does resizing the window render the cells as expected?
@andydotxyz yes I think this is a duplicate of #3034. Resizing the window causes the cells to appear.
This is fixed on develop I am pretty sure. Please re-open if not.