I am trying to collect data through ipywidgets. The objective once all the fields are filled , pressing the submit button should populate a row in a data frame. I wrote the following code
class record():
def __init__(self):
self.id = widgets.Text(description='id')
self.paper = widgets.Text(description='paper')
self.objective = widgets.Text(description='objective')
self.language = widgets.Text(description='language')
self.citations = widgets.Text(description='citations')
self.notes = widgets.Text(description='notes')
self.button = widgets.Button(description="Submit")
self.button.on_click(self.on_button_clicked)
display(self.id, self.paper, self.objective, self.language,self.citations,self.notes,self.button)
def on_button_clicked(self,b):
data = ('|').join([self.id.value,self.paper.value,self.objective.value,self.language.value,self.citations.value,self.notes.value])
populate(data)
r =record()
The populate method has the code to populate the entries to the dataframe. id, paper, objective, language, citations, and notes are the column names of the data frame. Populate methods reads a saved dataframe adds an additional row and saves it. I am new to using ipywidgets how to call the populate function on button press?
