有两个问题。一种是,当我单击组合框的下拉部分时,所有选项都是白色背景上的几乎是白色的超级暗淡的文本,这真的很难看到。 为了解决这个问题,我想更改主题,但也要控制字体大小和颜色。 但是,更改组合框.config的字体似乎仅更改所选内容,但列表仍为相同的小字体。 香港专业教育学院试图改变整体主题,但似乎没关系,我把它什么都没有改变。 谢谢
import os, sys
from tkinter import *
from tkinter import ttk
root = Tk()
#s = ttk.Style()
#root.style = ttk.Style()
#('clam', 'alt', 'default', 'classic')
root.style.theme_use("clam")
root.geometry("500x500+400+400")
# Get project list
currentprojects = './dummy/projects'
currentprojectslist = os.listdir(currentprojects)
currentprojectslist.sort()
def findshots(*args):
try:
project = projectmenuvar.get()
print("Project selected: ", project)
# get shot list
currentshots = "{}/{}/shots".format(currentprojects, project)
currentshotslist = os.listdir(currentshots)
currentshotslist.sort()
shotsmenu.set(currentshotslist[0])
shotsmenu['values'] = currentshotslist
except:
print("error passing")
pass
# def onShotChange(*args):
# print("shot changed: ", shotsmenuvar.get())
projectmenuvar = StringVar()
projectmenuvar.trace("w", findshots)
projectmenu = ttk.Combobox(root, textvariable=projectmenuvar, values=currentprojectslist)
projectmenu.config(width=50,)
projectmenu.pack()
shotsmenuvar = StringVar()
#shotsmenuvar.trace('w', onShotChange)
shotsmenu = ttk.Combobox(root, values=['--None--'])
shotsmenu.config(width=50)
shotsmenu.pack()
# select the first project
projectmenuvar.set(currentprojectslist[0])
root.mainloop()