Skip to content
Snippets Groups Projects
Commit ab927536 authored by Toumji Abdallah's avatar Toumji Abdallah
Browse files

QoL Added a Button to fill empty cells in a table with n/a

parent dabfdcaf
No related branches found
No related tags found
No related merge requests found
......@@ -117,7 +117,7 @@ class Form:
self.current_row += 10
help_label = tk.Label(self.frame, image=self.help_icon)
help_label.grid(row=self.current_row, column=3)
create_tool_tip(help_label, self.form[0]["description"])
create_tool_tip(help_label, self.form[1]["description"])
self.entries.append(text_entry)
def is_valid_mandatory(self):
......@@ -250,11 +250,14 @@ class Form:
self.validation_label.grid(row=self.current_row + 1, column=4)
create_tool_tip(self.validation_label, 'Every required field must be filled to validate the form.\n'
'The row must be filled entirely in each named column.\n'
'If an information is missing, fill the cell with N/A.')
'If an information is missing, fill the cell with n/a.')
# Display the recommendation as text at the right of the table.
recommendation_frame = tk.Frame(self.frame)
recommendation_frame.grid(row=0, column=6, rowspan=10)
null_to_na_button = tk.Button(recommendation_frame, text='Replace empty cells by n/a', command=self.null_to_na_tsv)
null_to_na_button.pack()
recommendation_label = tk.Label(recommendation_frame, text='Recommendation:', font=('Arial', 12, 'bold'))
recommendation_label.pack()
recommendation_text = tk.Text(recommendation_frame, height=10, width=50)
......@@ -266,6 +269,20 @@ class Form:
self.name_style[self.form[1][column]['requirement level']])
recommendation_text.config(state=tk.DISABLED)
def null_to_na_tsv(self):
"""This method is used to replace the empty cells or '' cells of the table by 'n/a'.
Only the empty cells in a row where at least one cell is filled will be replaced.
"""
is_null_df = self.table.model.df.isnull()
for i in range(len(self.table.model.df)):
if not is_null_df.iloc[i].all():
for j in range(len(self.table.model.df.columns)):
if is_null_df.iloc[i][j] or self.table.model.df.iloc[i, j] == '':
self.table.model.df.iloc[i, j] = 'n/a'
self.table.redraw()
def save_form_tsv(self, path):
"""This method is used to save the form in a tsv file.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment