小编med*_*wed的帖子

如何从 golang fyne 容器中删除对象

我正在开发 GUI 应用程序,需要动态添加和删除 gui 元素,我想知道是否有办法从 golang fyne 容器中删除元素。在下面的示例代码中,我创建了容器并动态添加元素,现在我希望能够删除这些元素而不是隐藏它们。(我尝试的一个“解决方案”是创建新容器,填充它并重置窗口内容,但它闪烁,我不喜欢它)。

package main

import (
    "fyne.io/fyne"
    "fyne.io/fyne/app"
    "fyne.io/fyne/canvas"
    "fyne.io/fyne/layout"
    "fyne.io/fyne/widget"
    "image/color"
    "strconv"
    "time"
)

type Input struct {
    Id       string
    ThumbUrl string
}

func (input Input) GetContainer() *fyne.Container {
    thumbImg := canvas.NewText("There", color.White)
    group := widget.NewGroup(input.Id, thumbImg)
    ret := fyne.NewContainerWithLayout(layout.NewVBoxLayout(), group)
    return ret
}

type Segment struct {
    Id           string
    Inputs       []Input
    InputsColumn *fyne.Container
}

func (seg *Segment) GetSegment() fyne.CanvasObject {
    first := true
    var inputsColumn *fyne.Container
    for _, in := range seg.Inputs …
Run Code Online (Sandbox Code Playgroud)

user-interface go fyne

5
推荐指数
1
解决办法
2045
查看次数

标签 统计

fyne ×1

go ×1

user-interface ×1