Skip to content

Incorrect row header width in widget.Table #4370

Closed
@vinser

Description

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

Neither SetColumnWidth nor template in CreateHeader do not set row header width up.
See the first fixed column on screenshot below

How to reproduce

Run the code below

Screenshots

image

Example code

import (
	"fmt"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

func main() {
	myApp := app.New()
	w := myApp.NewWindow("Table with Borders")

	t := widget.NewTableWithHeaders(
		func() (int, int) { return 5, 5 },
		func() fyne.CanvasObject {
			return widget.NewLabel("Cell 000, 000")
		},
		func(id widget.TableCellID, o fyne.CanvasObject) {
			label := o.(*widget.Label)
			label.SetText(fmt.Sprintf("Cell %d, %d", id.Row, id.Col))
		})

	t.SetColumnWidth(-1, 100)

	t.CreateHeader = func() fyne.CanvasObject {
		return widget.NewLabel("Row 000")
	}

	t.UpdateHeader = func(id widget.TableCellID, o fyne.CanvasObject) {
		l := o.(*widget.Label)
		if id.Col == -1 {
			l.SetText(fmt.Sprintf("Row %d", id.Row))
		} else {
			l.SetText(fmt.Sprintf("Column %d", id.Col))
		}
	}

	content := container.NewBorder(nil, nil, nil, nil, t)

	w.Resize(fyne.NewSize(400, 300))
	w.CenterOnScreen()
	w.SetContent(content)
	w.ShowAndRun()
}

Fyne version

2.4.1

Go compiler version

1.21.3

Operating system and version

Ubuntu 22.04 arm64, Windows 10 amd64

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions