Un exemple de mini applet: le pivot de Gauß#
%display plain
import ipywidgets
M = random_matrix(QQ, 5, 7)
M
rowIndices = list(range(M.nrows()))
rowIndices
L1 = ipywidgets.Dropdown(description="L1", options=rowIndices)
L2 = ipywidgets.Dropdown(description="L2", options=rowIndices)
L1
L1.value
Lambda = ipywidgets.Text()
Lambda
Lambda.value
Echange = ipywidgets.Button(description="Echange"); Echange
Matrix = ipywidgets.Output()
Matrix
def update():
Matrix.clear_output(wait=True)
with Matrix:
display(M)
update()
App = ipywidgets.VBox([L1, L2, Lambda, Echange, Matrix])
App
def echange(context):
l1 = L1.value
l2 = L2.value
M[l1], M[l2] = M[l2], M[l1]
update()
Echange.on_click(echange)