登录
首页 >  Golang >  Go问答

Fyne 表无法显示初始数据

来源:stackoverflow

时间:2024-02-27 22:36:30 345浏览 收藏

在IT行业这个发展更新速度很快的行业,只有不停止的学习,才不会被行业所淘汰。如果你是Golang学习者,那么本文《Fyne 表无法显示初始数据》就很适合你!本篇内容主要包括##content_title##,希望对大家的知识积累有所帮助,助力实战开发!

问题内容

我有一个正在填充数据的 fyne 表

type transaction struct {
    Name   string
    Amount float64
    Date   time.Time
    Memo   string
}

var transactions []transaction

func init() {// Data population omitted }

func makeCenter() *fyne.Container {
    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(YYYYMMDD))
            case 2:
                o.(*widget.Label).SetText(fmt.Sprintf("%.2f", transactions[i.Row].Amount))
            case 3:
                o.(*widget.Label).SetText(transactions[i.Row].Memo)
            }
        },
    )
    table.SetColumnWidth(0, 200)
    table.SetColumnWidth(1, 100)
    table.SetColumnWidth(2, 100)
    table.SetColumnWidth(3, 300)
    split := container.NewHSplit(makeLeftSidebar(), table)
    split.Offset = 0.2
    return container.NewMax(split)
}

当我的窗口最初显示时,表格没有数据

如果我单击任何单元格,数据就会填充

我已通过调试器运行此命令,发现创建 ui 时不会调用 newtablecreate 函数。只有单击后,我才能在 create 函数中得到中断。

[更新] 此问题是一个已知错误,在 https://github.com/fyne-io/fyne/issues/3198 和 https://github.com/fyne-io/fyne/issues/3034 中引用。


正确答案


听起来应该在 GitHub 上的错误跟踪器中列出而不是在这里......

以上就是《Fyne 表无法显示初始数据》的详细内容,更多关于的资料请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>