mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-07 19:02:50 +08:00
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/app"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/data/binding"
|
|
"fyne.io/fyne/v2/theme"
|
|
"fyne.io/fyne/v2/widget"
|
|
"strconv"
|
|
)
|
|
|
|
var w fyne.Window
|
|
|
|
func main() {
|
|
a := app.NewWithID("io.fyne.demo")
|
|
a.SetIcon(theme.FyneLogo())
|
|
w = a.NewWindow("Fyne Demo")
|
|
Regen(w)
|
|
w.Resize(fyne.NewSize(1080, 720))
|
|
w.ShowAndRun()
|
|
}
|
|
|
|
func Regen(w fyne.Window) {
|
|
tabs := container.NewDocTabs()
|
|
for _, datum := range generateData(600) {
|
|
tabs.Append(newItemTab(&datum))
|
|
}
|
|
w.SetContent(tabs)
|
|
}
|
|
|
|
func generateData(n int) (result []int) {
|
|
for i := 0; i < n; i++ {
|
|
result = append(result, i)
|
|
}
|
|
return
|
|
}
|
|
|
|
func newItemTab(i *int) *container.TabItem {
|
|
c := container.NewVBox(
|
|
BindIntWithLabel(i),
|
|
widget.NewButton("Regen", func() {
|
|
Regen(w)
|
|
}),
|
|
)
|
|
return container.NewTabItemWithIcon(strconv.Itoa(*i), theme.MenuIcon(), c)
|
|
}
|
|
|
|
func BindIntWithLabel(k *int) *widget.Label {
|
|
b := binding.BindInt(k)
|
|
return widget.NewLabelWithData(binding.IntToString(b))
|
|
}
|
|
|
|
func BindIntWithEntry(k *int) *widget.Entry {
|
|
b := binding.BindInt(k)
|
|
return widget.NewEntryWithData(binding.IntToString(b))
|
|
}
|