-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Colors are shown as numbers. It would be nice to see them visually.

Suggestion from Copilot:
package main
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Table Example")
data := [][]string{
{"Row 1, Col 1", "Row 1, Col 2"},
{"Row 2, Col 1", "Row 2, Col 2"},
}
table := &widget.Table{
Length: func() (int, int) {
return len(data), len(data[0])
},
CreateCell: func() fyne.CanvasObject {
// Create a container with a colored background and a label
background := canvas.NewRectangle(color.White)
label := canvas.NewText("", color.Black)
return container.NewMax(background, label)
},
UpdateCell: func(id widget.TableCellID, cell fyne.CanvasObject) {
// Update the label text
cont := cell.(*fyne.Container)
label := cont.Objects[1].(*canvas.Text)
label.Text = data[id.Row][id.Col]
// Change the background color of specific cells
background := cont.Objects[0].(*canvas.Rectangle)
if id.Row == 1 && id.Col == 1 {
background.FillColor = color.RGBA{R: 255, G: 0, B: 0, A: 255} // Red
} else {
background.FillColor = color.White
}
label.Refresh()
background.Refresh()
},
}
w.SetContent(container.NewMax(table))
w.Resize(fyne.NewSize(400, 200))
w.ShowAndRun()
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request