I have about 80 input boxes and want to use a ipy.widget button to reset any input to 0.
I have this code :
import pandas as pd
import numpy as np
import ipywidgets as ipw
from ipywidgets import *
value_1 = (ipw.FloatText(value=0,
description='Value:',
disabled=False,
layout = {'width':'200px'}
))
value_2 = (ipw.FloatText(value=0,
description='Value:',
disabled=False,
layout = {'width':'200px'}
))
value_3 = (ipw.FloatText(value=0,
description='Value:',
disabled=False,
layout = {'width':'200px'}
))
value_4 = (ipw.FloatText(value=0,
description='Value:',
disabled=False,
layout = {'width':'200px'}
))
value_5 = (ipw.FloatText(value=0,
description='Value:',
disabled=False,
layout = {'width':'200px'}
))
def reset_box(*args):
value_1.value = 0
value_2.value = 0
value_3.value = 0
value_4.value = 0
value_5.value = 0
btn2.on_click(reset_box)
Which works fine to reset the input box called value_1 through value_5, with the button called btn2
I was hoping to find a more efficient way to reset all the boxes which run from product_1-->product_21, units_1-->units_21, value_1-->value_21 and prices_1-->prices_21, which isnt just inputting them all into the function.