diff --git a/main.py b/main.py index 877288895d43a9ef31528b1732639644e8e55c61..1574751bb13eb19a64353aa51cc094d446cafeab 100644 --- a/main.py +++ b/main.py @@ -17,7 +17,7 @@ from datetime import datetime # start the main app: root = tk.Tk() -root.title('AGREEPrep - Analytical Greenness Metric for Sample Preparation') +root.title('AGREEprep - Analytical Greenness Metric for Sample Preparation') root.geometry('760x450') root.iconbitmap('AGREEPrep_icon.ico') # fix the window dimensions: @@ -188,12 +188,12 @@ def reset_scores(): criteria[1].radiovar.set(5) criteria[2].radiovar.set(2) criteria[3].radiovar.set(4) - criteria[4].radiovar.set(4) + criteria[4].radiovar.set(1) criteria[5].radiovar.set(3) criteria[6].radiovar.set(1) criteria[7].radiovar.set(4) - criteria[8].radiovar.set(3) - criteria[9].radiovar.set(4) + criteria[8].radiovar.set(2) + criteria[9].radiovar.set(3) create_plot() @@ -324,12 +324,12 @@ criteria[0].radiovar.set(1) criteria[1].radiovar.set(5) criteria[2].radiovar.set(2) criteria[3].radiovar.set(4) -criteria[4].radiovar.set(4) +criteria[4].radiovar.set(1) criteria[5].radiovar.set(3) criteria[6].radiovar.set(1) criteria[7].radiovar.set(4) -criteria[8].radiovar.set(3) -criteria[9].radiovar.set(4) +criteria[8].radiovar.set(2) +criteria[9].radiovar.set(3) def calculate_score(): @@ -458,7 +458,7 @@ class Report: # insert title (Helvetica, 'B'old, 14 pt): self.pdf.set_font('Helvetica', 'B', 18) self.pdf.ln(20) - self.pdf.cell(100, 12, 'AGREEPrep') + self.pdf.cell(100, 12, 'AGREEprep') self.pdf.set_font('Helvetica', '', 12) self.pdf.ln(10) self.pdf.multi_cell(55, 4, 'Analytical Greenness Metric for Sample Preparation') @@ -529,7 +529,7 @@ class Report: create_report_field('8.', self.tabs[7], self.criteria[7], ('Approximate energy consumption per analysis [W]: ' + - str(round(float(self.criteria[7].valuevar.get()), 2)))) + str(round(float(self.criteria[7].valuevar.get()), 2)))) create_report_field('9.', self.tabs[8], self.criteria[8], (self.criteria[8].optionvar.get())) @@ -619,11 +619,14 @@ tab3 = Tab(tab_no='3', title='Sustainability and renewability of materials', text2='Ratio of the mass of sustainable and renewable materials to the total ' 'mass of materials used:', criterion=criteria[2]) -tab3_choices = {'No reagents or only sustainable and renewable materials are used': 1.0, +tab3_choices = {'Only sustainable and renewable materials are used several times': 1.0, '> 75% of reagents and materials are sustainable or renewable': 0.75, - '50-75% of reagents and materials are sustainable or renewable': 0.50, + '50-75% of reagents and materials are sustainable or renewable and can only be used once': 0.50, '25-50% of reagents and materials are sustainable or renewable': 0.25, - '< 25% of reagents and materials are sustainable or renewable': 0} + '< 25% of reagents and materials are sustainable or renewable and can only be used once': 0, + 'Sustainable and renewable materials used several times': 1.0, + 'Materials are not sustainable or renewable and are used several times': 0.5, + 'Materials are not sustainable or renewable and are disposable': 0,} dropdown3 = ttk.OptionMenu(tab3.frame, criteria[2].optionvar, criteria[2].optionvar.get(), *tab3_choices.keys(), command=lambda x: change_dropdown(criteria[2], tab3_choices)) # the ttk style for OptionMenu does not include a style for the tk dropdown menu, @@ -702,7 +705,7 @@ entry5.bind('<Return>', calc_crit_5) ttk.Button(tab5.frame, text='Set', command=calc_crit_5, width=8).grid(column=0, row=3, padx=80, pady=8, sticky='w') # --------------------------- TAB6 --------------------------- -tab6 = Tab(tab_no='6', title='Smaple throughput', +tab6 = Tab(tab_no='6', title='Sample throughput', text1='Sample throughput determines the overall duration of the sample preparation stage.', text2='Input the number of samples that can be prepared in one hour:', criterion=criteria[5]) @@ -730,6 +733,7 @@ def calc_crit_6(event=None): create_plot() + entry6.bind('<Return>', calc_crit_6) ttk.Button(tab6.frame, text='Set', command=calc_crit_6, width=8).grid(column=0, row=3, padx=80, pady=8, sticky='w') @@ -800,7 +804,7 @@ dropdown7b.grid(column=0, row=5, padx=8, pady=8, sticky='w') # remember to include a drop-down list of generic requirements for typical devices! tab8 = Tab(tab_no='8', title='Energy consumption', text1='The power consumption per analysis should be minimized.', - text2='Input the energy consumption [W] per sample, accounting for the sample throughput:', + text2='Input the energy consumption [Wh] per sample, accounting for the sample throughput:', criterion=criteria[7]) f8 = tk.Frame(tab8.frame, border=2, background=colors['accent']) @@ -813,13 +817,13 @@ def calc_crit_8(event=None): try: if criteria[7].valuevar.get() == 'Input': criteria[7].textvar.set(1.0) - elif float(criteria[7].valuevar.get()) / 1000 >= 0.5: # /1000 to input W instead of kW + elif float(criteria[7].valuevar.get()) >= 500: criteria[7].textvar.set(0) - elif float(criteria[7].valuevar.get()) / 1000 <= 0.01: + elif float(criteria[7].valuevar.get()) <= 10: criteria[7].textvar.set(1.0) else: criteria[7].textvar.set( - abs(-0.264 * log(float(criteria[7].valuevar.get()) / 1000) + 0.1606)) + abs(-0.252 * log(float(criteria[7].valuevar.get())) + 1.5477)) except ValueError: messagebox.showerror(title='Value error', message='The amount has to be a float or an integer, e.g. 0.14 or 21.') @@ -829,66 +833,6 @@ def calc_crit_8(event=None): entry8.bind('<Return>', calc_crit_8) ttk.Button(tab8.frame, text='Set', command=calc_crit_8, width=8).grid(column=0, row=3, padx=80, pady=8, sticky='w') -# label_tab8 = ttk.Label(tab8.frame, text='If more than one sample is prepared with the sample preparation ' -# 'device, the energetic requirement for the device is divided ' -# 'by the number of samples.', -# wraplength=280) -# label_tab8.grid(column=0, row=4, sticky='w') - -label_tab8_2 = ttk.Label(tab8.frame, text='Alternatively, select one or several generic devices for ' - 'a rough estimate based on the throughput provided in Criterion #6:', - wraplength=280) -label_tab8_2.grid(column=0, row=5, sticky='w') - -multiselect_menu8 = ttk.Menubutton(tab8.frame, text='Select used devices') -multiselect_menu8.grid(column=0, row=6, padx=8, pady=8, sticky='w') - - -class Device: - def __init__(self, name, wattage): - self.name = name - self.wattage = wattage - self.state = tk.IntVar() - - -# Modify this function to calculate the score: -def crit_8_rough_estimate(): - comb_wattage = 0 - for instrument in instruments: - if instrument.state.get(): - comb_wattage += instrument.wattage - else: - pass - if criteria[5].valuevar.get() == 'Input': - messagebox.showerror(title='Value error', - message='Please fill in the throughput value in Criterion #6.') - else: - criteria[7].valuevar.set(comb_wattage / float(criteria[5].valuevar.get())) - calc_crit_8() - - -# open an external list of sample prep instruments and corresponding wattage {'Freeze dryer: 1000,} -def load_dict(): - dict_of_devices = open('list_of_devices.config', 'r').read() - dvcs = ast.literal_eval(dict_of_devices) - return dvcs - - -devices = load_dict() - -# create a list of objects of the Devices class from the external dictionary -instruments = [] -for device in devices: - instruments.append(Device(name=device, wattage=devices[device])) - -multiselect_menu8.menu = tk.Menu(multiselect_menu8, tearoff=0) -multiselect_menu8['menu'] = multiselect_menu8.menu - -for instrument in instruments: - multiselect_menu8.menu.add_checkbutton(label=instrument.name, variable=instrument.state, - command=crit_8_rough_estimate, - background=colors['background'], activebackground=colors['accent']) - # --------------------------- TAB9 --------------------------- tab9 = Tab(tab_no='9', title='Post-sample preparation configuration for analysis', text1='The prepared sample matrix should be compatible with the analytical instrument, ' @@ -922,7 +866,7 @@ tab10 = Tab(tab_no='10', title='Operator\'s safety', 'labelling used chemicals) and physical nature:', criterion=criteria[9]) -tab10_choices = {'No hazards': 1.0, +tab10_choices = {'No hazards or no exposure': 1.0, '1 hazard': 0.75, '2 hazards': 0.50, '3 hazards': 0.25, @@ -953,3 +897,4 @@ def main(): main() +