gpt4 book ai didi

user-interface - 如何更改 GUI 组件的颜色

转载 作者:IT王子 更新时间:2023-10-29 02:06:31 25 4
gpt4 key购买 nike

我正在尝试使用 fyne 的演示代码:

package main
import (
"fyne.io/fyne/app"
"fyne.io/fyne/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Hello")
w.SetContent(
widget.NewVBox(
widget.NewLabel("Hello Fyne!"),
widget.NewButton("Quit", func(){a.Quit()} ),
),
)
w.ShowAndRun()
}

它运行正常,但我想将标签的颜色更改为蓝色,将按钮的颜色更改为绿色。我看到有 theme但这似乎适用于整个应用程序,而不适用于单个元素。

不同的颜色如何应用于不同的 GUI 组件?感谢您的帮助。

最佳答案

这是在 fyne-io/fyne issue 255 中提出的

I propose individual styles assignable to widgets:

但是:

Part of our design is to promote application consistency - a user experience that cannot be trivially compromised by "this label is larger" or "this dropdown is transparent".

Fyne's approach to this is that widgets have a set style (that can be themed) but the canvas remains fully available to do whatever specific designs a developer chooses to code.

因此 native 不支持更改单个按钮的颜色。

Andy Williamsfyne-io/fyne 的作者/主要贡献者, 添加 in the comments :

This is quite correct.
The only way to have a widget that is is styled differently to the standard colours is to implement a custom widget and add that functionality yourself.

There are, however, some semantic styles, a button can be “primary, for example, in which case it will use the theme highlight color

关于user-interface - 如何更改 GUI 组件的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57651536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com