Andreas Gohr
Andreas Gohr

Reputation: 4935

How to set default theme from code using the fyne GUI framework?

I can run my Fyne application with FYNE_THEME=light to make it use a light background and running without this var it will default to dark. Is there a way to reverse this behaviour? Having the application start with the light theme by default?

Upvotes: 3

Views: 3871

Answers (2)

yebowhatsay
yebowhatsay

Reputation: 341

add

os.Setenv("FYNE_THEME", "light")

in func main() before you show and run the window.

App would start with light theme by default.

Upvotes: 4

andy.xyz
andy.xyz

Reputation: 3265

You set the theme globally by running fyne_settings to change user theme.

go get fyne.io/fyne/cmd/fyne_settings

All fyne apps will respect the configuration set in that app.

If your intent is to override the user theme (be careful about doing this as their settings will be ignored) you can configure the app settings in code:

myApp.Settings().SetTheme(theme.LightTheme())

Upvotes: 3

Related Questions