0

我正在尝试使用 enaml 为我的应用程序创建视图。我想知道如何设置窗口小部件的背景颜色。我看到我可以使用样式表为窗口内的东西设置颜色,但我似乎找不到设置窗口颜色的方法。

enamldef Main(MainWindow):
StyleSheet:
    Style:
        element = 'PushButton'

        Setter:
            field = 'background'
            value = 'indianred'

title << ""
initial_size = (1000,500)
initial_position = (300,150)
icon = loadIcon(normpath('TitleIcon.png'))
visible = True
always_on_top = True
style_class << "WindowStyle"

MyMenuBar:
    pass

Container:
    #constraints = [vbox(label, label, spacing=0)]
    PushButton:
        text = "one"
    pass
4

1 回答 1

0

您只需要设置正确的元素样式:

enamldef Main(MainWindow):
    StyleSheet:
        Style:
            element = 'Main'
            Setter:
                field = 'background'
                value = 'indianred'
    Container:
        PushButton:
            text = "one"

示例截图

于 2016-03-06T19:03:21.110 回答