2017-06-21 10 views
0

私はipywidgets.widgets.Checkboxを使用しています。チェックボックスイベントを処理する方法はありますか?助けてください。私は初心者です。Python ipywidgets checkbox events

編集:チェックボックスのリストを作成するにはどうすればよいですか?

答えて

1

直接イベントはありませんが、observeeventを使用できます。それはおそらくあなたが望むものより多くの出来事を作り出すので、それらを1つに絞りたいかもしれません。

from IPython.display import display 
from ipywidgets import Checkbox 

box = Checkbox(False, description='checker') 
display(box) 

def changed(b): 
    print(b) 

box.observe(changed) 

ウィジェットの「リスト」を作成するには、コンテナwidgetsを使用できます。リンクから:

from ipywidgets import Button, HBox, VBox 

words = ['correct', 'horse', 'battery', 'staple'] 
items = [Button(description=w) for w in words] 
left_box = VBox([items[0], items[1]]) 
right_box = VBox([items[2], items[3]]) 
HBox([left_box, right_box]) 
+0

助けてくれてありがとう! – Sudharsan