您可以在分配给的过程中保留有关的通知
options:
with search_result.hold_trait_notifications(): search_result.options = titles
从而:
search_text = widgets.Text(description = 'Search') search_result = widgets.Select(description = 'Select table')def search_action(sender): phrase = search_text.value df = search(phrase) # A function that returns the results in a pandas df titles = df['title'].tolist() with search_result.hold_trait_notifications(): search_result.options = titles
请参阅下面的hmelberg解释
“错误的根源是该窗口小部件还具有value属性,并且该值可能不在新的选项列表中。因此,窗口小部件的值可能会在短时间内被“孤立”,从而产生错误。”
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)