如何更改GUI组件的颜色 [英] How to change color of GUI components

查看:152
本文介绍了如何更改GUI组件的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循 fyne 的演示代码:

I am trying following demo code of 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 ,但这似乎是整个应用,而不是针对单个元素.

It runs all right but I want to change color of label to blue and that of button to green. I see there is theme but that seems to be for entire application and not for individual elements.

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

How can different colors be applied to different GUI components? Thanks for your help.

推荐答案

由于Fyne中的标准小部件不支持自定义,因此没有简短的答案(除非我们不建议这样做).

As the standard widgets in Fyne do not support customisation there is no short answer to this (other than we don't advise it).

如果由于用户的某些正当理由而必须执行此操作,则应查看我们的开发人员文档,其中简要介绍了编写

If you have to do this, for some valid reason that your users require, then you should look at our developer documentation which has a brief introduction to writing custom widgets. However we aim to make this process easier in release 1.2 later this year.

仅在Fyne工具包上方重申一下意见,目的是创建一种简单易编程的一致用户体验.每次创建自定义窗口小部件以便拥有自定义颜色或样式时,都可能使用户感到困惑,并使维护代码变得更加困难.

Just to re-iterate comments above the Fyne toolkit is aiming to create a consistent user experience that is simple and fast to program. Every time you create a custom widget so that you can have custom colours or styles you may be confusing your user and you will be making it much harder to maintain the code.

这篇关于如何更改GUI组件的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆