简体   繁体   中英

Is it cause performance issue to use multiple Window.SetContent in go with fyne api

I am developing an application but i need use multiple Window.SetContent method of fyne api but i am worry about is it will decrease performance of my application. Is the oldest Window.SetContent still running in background? Or is it stopped working after i call second Window.SetContent method.Here is test code, in my real application i need use more Window.SetContent method than test code. I still did not find a solution making my app usable without using second Window.SetContent method as in the test code.

package main

import (
    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/widget"
)

func main() {
    a := app.New()
    
    w := a.NewWindow("testing")
    
    w.Resize(fyne.NewSize(400, 400))
    
    testButton1 := widget.NewButton("test1", func(){})
    
    testButton2 := widget.NewButton("go to test1 button", func(){
        w.SetContent(testButton1)
    })
    
    w.SetContent(testButton2)
    
    w.ShowAndRun()
    
}

Setting the window content must check it fits and other things that may be slow. Using a container and replacing its content is likely more efficient.

This is also easier to make reusable components as widgets should not require they are using the whole window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM