【问题标题】:can't set background color ttk python os x using styles无法使用样式设置背景颜色 ttk python os x
【发布时间】:2011-07-17 12:38:54
【问题描述】:

使用此代码片段,我希望标签的背景颜色为红色。 def createWidgets(self):

    style = ttk.Style()
    style.configure("Red.TLabel", foreground="green", background="red")

    self.label1 = ttk.Label(textvariable=self.numberArray[0][0],style="Red.TLabel")
    self.label1.pack()

我得到了绿色的前景色,但我无法更改背景色。 这是在 OS X 上。我正在使用 ActiveState 的 tcl 和 python。 Python 3.2 和 2.7 也会出现同样的问题

【问题讨论】:

    标签: python macos operating-system tkinter ttk


    【解决方案1】:

    您有时会尝试更改根据元素选项应该存在的选项,但它没有效果。 例如,您不能修改 Mac OS X 使用的“aqua”主题中按钮的背景颜色。虽然这些情况有正当理由,但目前并不容易发现它们,这有时会使实验令人沮丧。

    取自本教程http://www.tkdocs.com/tutorial/styles.html

    【讨论】:

      猜你喜欢
      • 2014-07-03
      • 2019-06-25
      • 2011-04-30
      • 2013-07-12
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      • 2012-06-04
      • 2014-03-29
      相关资源
      最近更新 更多