manual_teachbooks/book/examples/grading.py
2024-05-27 09:50:01 +02:00

16 lines
476 B
Python

from IPython.display import display
import ipywidgets as widgets
def check(f):
def wrapper(*args, **kwargs):
output = widgets.Output()
button = widgets.Button(description="Check Answer(s)")
@output.capture(clear_output=True,wait=True)
def _inner_check(button):
try:
f(*args, **kwargs)
except:
print("Something went wrong, have you filled all the functions and run the cells?")
button.on_click(_inner_check)
display(button, output)
return wrapper