【问题标题】:How do you change the color of the words in a Python Tkinter OptionMenu如何更改 Python Tkinter OptionMenu 中单词的颜色
【发布时间】:2015-06-30 09:04:30
【问题描述】:

我正在尝试制作颜色的下拉菜单。红绿蓝黄。我希望选项框中的单词用他们尊敬的名字着色。所以当用户点击箭头打开optionMenu时,Option red会有红色字母。蓝色将有蓝色字母等等。

这可能吗?

谢谢。

【问题讨论】:

  • 或者如果有办法使用不同的 tkinter 对象来做到这一点

标签: python tkinter optionmenu


【解决方案1】:

所以你只需要使用OptionMenu.entryconfig(*index of item*, background = *color)

m.entryconfig(0, background="GREEN")
m.entryconfig(1, background = "RED")

【讨论】:

    【解决方案2】:

    尝试使用fg(或foreground)和bg(或background)选项。如果a 是菜单,请使用: a.entryconfig( optionindex , bg=" color_name " ) 用于背景,以及 a.entryconfig( optionindex , bg= " color_name " ) 前台。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-13
      • 2020-10-06
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多