def _recolorTree(widget, oldpalette, newcolors):
# Change the colors in a widget and its descendants.
# Change the colors in <widget> and all of its descendants,
# according to the <newcolors> dictionary. It only modifies
# colors that have their default values as specified by the
# <oldpalette> variable. The keys of the <newcolors> dictionary
# are named after widget configuration options and the values are
# the new value for that option.
for dbOption in newcolors.keys():
option = string.lower(dbOption)
try:
value = str(widget.cget(option))
except:
continue
if oldpalette is None or value == oldpalette[dbOption]:
apply(widget.configure, (), {option : newcolors[dbOption]})
for child in widget.winfo_children():
_recolorTree(child, oldpalette, newcolors)
评论列表
文章目录