def _new_state(self, widget, newtext):
widget = self.nametowidget(widget)
if not newtext:
goodstates = ["disabled"]
font_extra = 0
else:
# set widget state according to what has been entered in the entry
newstates = set(newtext.split()) # eliminate duplicates
# keep only the valid states
goodstates = [state for state in newstates if state in states]
# define a new font size based on amount of states
font_extra = 2 * len(goodstates)
# set new widget state
for widget in self.update_widgets:
reset_state(widget) # remove any previous state from the widget
widget.state(goodstates)
# update Ttk Button font size
self._set_font(font_extra)
return 1
评论列表
文章目录