【问题标题】:Is it possible to color a specific item in a Tkinter combobox list? (in python)是否可以为 Tkinter 组合框列表中的特定项目着色? (在蟒蛇中)
【发布时间】:2021-11-11 02:19:38
【问题描述】:

这是我的代码:


import tkinter as tkp

from tkinter import ttk

from tkinter import messagebox

window = tkp.Tk()
window.geometry("600x500")

if __name__ == "__main__" :

    cities = ['OIII','OITT','OIHH','OISS','OIBB']
    txtCityName = ttk.Combobox(window, width = 13, height=15, values=cities, font='sans 10 bold')

    txtCityName.pack()
    window.mainloop()

我想将列表框上的“OIHH”和“OISS”颜色更改为红色,将其他颜色更改为蓝色。 提前感谢您的帮助。

【问题讨论】:

  • 您的标题提到了一个列表框,但您的代码中没有列表框。
  • txtCityName = ttk.Combobox(window, width = 13, height=15, values=cities, font='sans 10 bold') ,城市是我的清单。如果你运行我的代码,你会看到下拉列表。

标签: python tkinter colors combobox


【解决方案1】:

不,您不能更改 ttk Combobox 下拉列表中项目的颜色。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-08
    • 1970-01-01
    • 2016-04-02
    • 2017-05-12
    相关资源
    最近更新 更多