Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing theme while application is running doesn't change some parameters on some widgets #4344

Closed
2 tasks done
pztrn opened this issue Oct 26, 2023 · 5 comments
Closed
2 tasks done
Labels
unverified A bug that has been reported but not verified
Milestone

Comments

@pztrn
Copy link

pztrn commented Oct 26, 2023

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

When changing theme from dark to light (or vice versa) some widgets like buttons doesn't change it's theme. E.g buttons doesn't change background until mouseover, never changes font color.

How to reproduce

  1. Create a window with tabs and buttons placed in tabs. Open that app.
  2. Open fyne_settings, change theme from dark to light (or vise versa).
  3. Switch back to running application, change active tab. Some buttons doesn't change it's background and almost no buttons changed font color.

Screenshots

image

Example code

I'll add code later if neccessary. Just create a window, put tabs in it, but some buttons in tabs containers.

Fyne version

2.3.5, 2.4.1

Go compiler version

1.21.3

Operating system and version

Arch Linux latest @ 20231026

Additional Information

No response

@pztrn pztrn added the unverified A bug that has been reported but not verified label Oct 26, 2023
@andydotxyz
Copy link
Member

You will need to provide code to replicate this. As you can see in fyne_demo and in our tests it does normally work.

@qiwentaidi
Copy link

qiwentaidi commented Oct 27, 2023

I think you can try this function

// https://github.com/fyne-io/fyne/issues/2996
func Refresh(tableapps ...*container.AppTabs) {
	for _, c := range tableapps {
		c.OnSelected = func(t *container.TabItem) {
			fyne.CurrentApp().Settings().SetTheme(fyne.CurrentApp().Settings().Theme())
		}
	}
}

@sdassow
Copy link
Contributor

sdassow commented Nov 20, 2023

Experiencing this effect as well, and didn't get around to isolate the code for testing yet. So for now just a comment.

@sdassow
Copy link
Contributor

sdassow commented Nov 21, 2023

Just isolated the code in question, and it does involve AppTabs like others also mentioned.
To reproduce, run it, click button to change theme in one tab, then switch to other tab and see the issue:

package main

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

func main() {
	a := app.New()
	w := a.NewWindow("Theme Test")

	foo := container.NewVBox(
		widget.NewButton("dark", func() {
			a.Settings().SetTheme(theme.DarkTheme())
		}),
		widget.NewButton("light", func() {
			a.Settings().SetTheme(theme.LightTheme())
		}),
	)

	bar := container.NewVBox(
		widget.NewButton("dark", func() {
			a.Settings().SetTheme(theme.DarkTheme())
		}),
		widget.NewButton("light", func() {
			a.Settings().SetTheme(theme.LightTheme())
		}),
	)

	tabs := container.NewAppTabs(
		container.NewTabItem("Foo", foo),
		container.NewTabItem("Bar", bar),
	)

	w.SetContent(tabs)
	w.ShowAndRun()
}

andydotxyz added a commit to andydotxyz/fyne that referenced this issue Jan 7, 2024
@dweymouth dweymouth added this to the D fixes (v2.4.x) milestone Jan 8, 2024
@andydotxyz andydotxyz modified the milestones: D fixes (v2.4.x), v2.4.4 Jan 8, 2024
@andydotxyz
Copy link
Member

Fixed on develop :)

andydotxyz added a commit that referenced this issue Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

5 participants