From df118c52864dac5981e64ff17ee592c141e8e789 Mon Sep 17 00:00:00 2001
From: Wojciech Wojnowski <wojciech.wojnowski@pg.edu.pl>
Date: Fri, 24 Apr 2020 04:58:24 +0000
Subject: [PATCH] Updated the re-set function, removed typos

---
 AGREE.py | 121 +++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 96 insertions(+), 25 deletions(-)

diff --git a/AGREE.py b/AGREE.py
index 92514d6..20eb383 100644
--- a/AGREE.py
+++ b/AGREE.py
@@ -35,7 +35,7 @@ canvas.pack()
 root.after(5000, root.destroy)
 root.mainloop()
 
-# **************** MAIN PROGRAM *******************************
+# **************** MAIN WINDOW  *******************************
 
 root = Tk()
 
@@ -79,15 +79,15 @@ def popup_bonus():
     def callback(event):
         webbrowser.open_new(event.widget.cget("text"))
 
-    popup_label1 = Label(win, text='v. 0.1 2020 \n(c) Gdańsk University of Technology', justify=LEFT)
+    popup_label1 = Label(win, text='v. 0.4 2020', justify=LEFT)
     popup_label1.grid(row=0, column=0, padx=8, pady=8)
 
-    popup_label2 = Label(win, text=r'http://www.chem.pg.edu.pl/kcha', fg='blue', cursor='hand2', justify=LEFT)
+    popup_label2 = Label(win, text=r'https://git.pg.edu.pl/p174235/AGREE', fg='blue', cursor='hand2', justify=LEFT)
     popup_label2.grid(row=1, column=0, padx=8, pady=8)
     popup_label2.bind('<Button-1>', callback)
 
     popup_label3 = Label(win,
-                         text='Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus convallis non sem ut aliquet. Praesent tempus fringilla suscipit. Phasellus tellus massa, semper et bibendum quis, rhoncus id neque. Sed euismod consectetur elit id tristique. Sed eu nibh id ante malesuada condimentum. Phasellus luctus finibus luctus. Pellentesque mi tellus, condimentum sit amet porta sit amet, ullamcorper quis elit. Pellentesque eu mollis nulla. Quisque vulputate, sem at iaculis vehicula, dui orci aliquet lectus, in facilisis odio dolor ut leo. Vivamus convallis hendrerit est luctus ornare. Nullam augue nisi, aliquam sit amet scelerisque hendrerit, pretium vel dui. Pellentesque sed tortor mollis, imperdiet quam quis, scelerisque erat. Vestibulum quis mollis dolor.',
+                         text='The Analytical Greenness calculator is a tool intended to aid the User in evaluating the environmental and occupational hazards associated with a particular analytical procedure based on the 12 principles of Green Analytical Chemistry. The result of the assessment is translated into a graph that is easy to interpret and contains an overall score, as well as an indication to what degree the evaluated procedure conforms to each of the 12 principles. It can be used to compare different methods in order to select the one with the lowest environmental impact, or to identify possible trouble spots in terms of "greenness" during conceptualization and development of novel analytical procedures.',
                          wraplength=300, justify=LEFT, bg='white')
     popup_label3.grid(row=2, column=0, padx=8, pady=8)
 
@@ -305,7 +305,9 @@ var_12 = 1.0
 def resetAllValues():
     global var_1, var_2, var_3, var_4, var_5, var_6, var_7, var_8, var_9, var_10, var_11, var_12
     global weight_1, weight_2, weight_3, weight_4, weight_5, weight_6, weight_7, weight_8, weight_9, weight_10, weight_11, weight_12
+    global var_1_text, amount_var, var_3_text, var_4_text, var_5a_text, var_5b_text, amount_var7, amount_var8a, amount_var8b, amount_var9, var_9_text, var_10_text, var_11a_text, amount_var11b
 
+    # re-set the variables:
     var_1 = 1.0
     var_2 = 1.0
     var_3 = 1.0
@@ -319,6 +321,7 @@ def resetAllValues():
     var_11 = 1.0
     var_12 = 1.0
 
+    # re-set the weights:
     weight_1.set(2)
     weight_2.set(2)
     weight_3.set(2)
@@ -332,6 +335,32 @@ def resetAllValues():
     weight_11.set(2)
     weight_12.set(2)
 
+    # re-set the dialogs
+    var_1_text.set('select')
+    amount_var.set('input')
+    var_3_text.set('select')
+    var_4_text.set('select')
+    var_5a_text.set('select')
+    var_5b_text.set('select')
+    # clear the list of selected CAS in Tab6:
+    clear_list()
+    amount_var7.set('input')
+    amount_var8a.set('input')
+    amount_var8b.set('input')
+    amount_var9.set('input')
+    var_9_text.set('select')
+    var_10_text.set('select')
+    var_11a_text.set('select')
+    amount_var11b.set(0.0)
+    # clear the selection boxes in Tab12:
+    global varA, varB, varC, varD, varE, varF, varG
+    varA.set(0.0)
+    varB.set(0.0)
+    varC.set(0.0)
+    varD.set(0.0)
+    varE.set(0.0)
+    varF.set(0.0)
+    varG.set(0.0)
     # re-draw the graph:
     chartPlotter()
 
@@ -454,7 +483,7 @@ var_1_text_choices = {'Remote sensing without sample damage': 1.0,
                       'Off-line analysis': 0.48,
                       'External sample pre- and treatment and batch analysis (reduced number of steps)': 0.30,
                       'External sample pre- and treatment and batch analysis (large number of steps)': 0.0}
-var_1_text.set('SAMPLING PROCEDURE')
+var_1_text.set('select')
 
 dropDown_1 = OptionMenu(tab1, var_1_text, *var_1_text_choices.keys())
 dropDown_1.config(wraplength=250, bg='white', justify=LEFT, width=40, anchor='w')
@@ -466,7 +495,10 @@ def change_dropdown_1(*args):
     # Define the global variable for Principle 1:
     global var_1
     var_1 = None
-    var_1 = var_1_text_choices[var_1_text.get()]
+    if var_1_text.get() == 'select':
+        var_1 = 1.0
+    else:
+        var_1 = var_1_text_choices[var_1_text.get()]
     print('var_1:' + str(var_1))
 
     chartPlotter()
@@ -544,7 +576,10 @@ dropDown_3.grid(sticky='w', row=2, column=0, padx=8, pady=8)
 def change_dropdown_3(*args):
     global var_3
     var_3 = None
-    var_3 = var_3_text_choices[var_3_text.get()]
+    if var_3_text.get() == 'select':
+        var_3 = 1.0
+    else:
+        var_3 = var_3_text_choices[var_3_text.get()]
     print('var_3:' + str(var_3))
     chartPlotter()
 
@@ -580,7 +615,10 @@ dropDown_4.grid(sticky='w', row=2, column=0, padx=8, pady=8)
 def change_dropdown_4(*args):
     global var_4
     var_4 = None
-    var_4 = var_4_text_choices[var_4_text.get()]
+    if var_4_text.get() == 'select':
+        var_4 = 1.0
+    else:
+        var_4 = var_4_text_choices[var_4_text.get()]
     print('var_4:' + str(var_4))
     chartPlotter()
 
@@ -635,11 +673,13 @@ def variableFive():
 
 # on change dropdown value, get the dictionary value and modify the global variable
 def change_dropdown_5a(*args):
-    var_5a.set(var_5a_text_choices[var_5a_text.get()])
+
+    if var_5a_text.get() == 'select':
+        var_5a.set(1.0)
+    else:
+        var_5a.set(var_5a_text_choices[var_5a_text.get()])
     print('var_5a:' + str(var_5a))
     variableFive()
-    # global var_5
-    # var_5 = var_5a.get() * var_5b.get()
 
     chartPlotter()
 
@@ -660,10 +700,10 @@ dropDown_5b.grid(sticky='w', row=4, column=0, padx=8, pady=8)
 
 
 def change_dropdown_5b(*args):
-    var_5b.set(var_5b_text_choices[var_5b_text.get()])
-    # print('var_5b:' + str(var_5b))
-    # global var_5
-    # var_5 = var_5a.get() * var_5b.get()
+    if var_5b_text.get() == 'select':
+        var_5b.set(1.0)
+    else:
+        var_5b.set(var_5b_text_choices[var_5b_text.get()])
     variableFive()
     print('var_5:' + str(var_5))
 
@@ -741,7 +781,6 @@ def clear_list():
 
 # create global variables
 global_list = []
-# if derivatization should be avoided, then shouldn't the highest value in the case in which derivatization agents are used be lower than 1.0?
 lbox_list = {
     # "None": 1.1,
     "5950-69-6": 1,
@@ -1063,7 +1102,7 @@ W_6 = weightChoice(10, 0, tab6, weight_6)
 # *****************************************************************************************************************
 #               TAB 7
 # *****************************************************************************************************************
-content_7 = tab(tab7, text1='Generation of a large volume of analytical waste should be avoided, and proper management'
+content_7 = tab(tab7, text1='Generation of a large volume of analytical waste should be avoided, and proper management '
                             'of analytical waste should be provided.', text2='Enter the amount of waste in g or mL:')
 
 amount_var7 = StringVar()
@@ -1165,16 +1204,35 @@ amount_var9 = StringVar(tab9)
 amount_var9.set('input')
 # Dictionary with options
 var_9_text_choices = {'None': 1.0,
-                      'FTIR': 1.0,  # what about vortexing, incubation, etc.? Mineralization?
+                      'FTIR': 1.0,
+                      'Hot plate solvent evaporation (<10 min)': 1.0,
+                      'Rotary evaporation': 1.0,
+                      'Needle evaporation': 1.0,
+                      'Ultrasound-assisted extraction': 1.0,
+                      'SPE and SPME': 1.0,
+                      'Microbiological assays': 1.0,
                       'Immunoassay': 1.0,
                       'Spectrofluorometry': 1.0,
                       'Titration': 1.0,
                       'UPLC': 1.0,
                       'UV-Vis Spectrometry': 1.0,
-                      'AAS': 0.5,
+                      'Energy dispersive X-ray fluorescence': 1.0,
+                      'Potentiometry': 1.0,
+                      'Non-instrumental detection': 1.0,
+
+                      'Hot plate solvent evaporation (10-150 min)': 0.5,
+                      'Accelerated solvent extraction': 0.5,
+                      'Supercritical fluid extraction': 0.5,
+                      'Microwave assisted extraction': 0.5,
+                      'Flame atomic absorption spectrometry': 0.5,
+                      'Electrothermal atomic absorption spectrometry': 0.5,
                       'GC': 0.5,
                       'ICP-MS': 0.5,
+                      'ICP-OES': 0.5,
                       'LC': 0.5,
+
+                      'Hot plate solvent evaporation (>150 min)': 0.0,
+                      'Soxhlet extraction': 0.0,
                       'NMR': 0.0,
                       'GC-MS': 0.0,
                       'LC-MS': 0.0,
@@ -1190,7 +1248,10 @@ dropDown_9.grid(sticky='w', row=2, column=0, padx=8, pady=8)
 def change_dropdown_9(*args):
     global var_9
     var_9 = 1.0
-    var_9 = var_9_text_choices[var_9_text.get()]
+    if var_9_text.get() == 'select':
+        var_9 = 1.0
+    else:
+        var_9 = var_9_text_choices[var_9_text.get()]
     print('var_9:' + str(var_9))
     chartPlotter()
 
@@ -1251,7 +1312,10 @@ dropDown_10.grid(sticky='w', row=2, column=0, padx=8, pady=8)
 def change_dropdown_10(*args):
     global var_10
     var_10 = None
-    var_10 = var_10_text_choices[var_10_text.get()]
+    if var_3_text.get() == 'select':
+        var_10 = 1.0
+    else:
+        var_10 = var_10_text_choices[var_10_text.get()]
     print('var_10:' + str(var_10))
     chartPlotter()
 
@@ -1270,7 +1334,7 @@ var_11a_text = StringVar(tab11)
 # Dictionary with options
 var_11a_text_choices = {'No': 1.0,
                         'Yes': 0.0}
-var_11a_text.set('Select')
+var_11a_text.set('select')
 
 dropDown_11a = OptionMenu(tab11, var_11a_text, *var_11a_text_choices.keys())
 dropDown_11a.config(wraplength=250, bg='white', justify=LEFT, width=40, anchor='w')
@@ -1278,7 +1342,9 @@ dropDown_11a.grid(sticky='w', row=2, column=0, padx=8, pady=8)
 
 
 def enabler_11b():
-    if float(var_11a_text_choices[var_11a_text.get()]) == 0.0:
+    if var_11a_text.get() == 'select':
+        return 'disabled'
+    elif float(var_11a_text_choices[var_11a_text.get()]) == 0.0:
         return 'enabled'
     else:
         return 'disabled'
@@ -1291,7 +1357,10 @@ amount_var11b.set(0.0)
 def change_dropdown_11a(*args):
     global var_11
     var_11 = 1.0
-    var_11 = var_11a_text_choices[var_11a_text.get()]
+    if var_11a_text.get() == 'select':
+        var_11 = 1.0
+    else:
+        var_11 = var_11a_text_choices[var_11a_text.get()]
     Label(tab11, text='Amount of toxic reagents or solvents in g or mL:', wraplength=300, justify=LEFT).grid(sticky='w', row=3, column=0, padx=8, pady=8)
     reagent_entry_11 = ttk.Entry(tab11, textvariable=amount_var11b, width=15, state=enabler_11b())
     reagent_entry_11.grid(sticky='w', row=4, column=0, padx=8, pady=8)
@@ -1299,7 +1368,9 @@ def change_dropdown_11a(*args):
     reagent_entry_11.bind('<Return>', change_dropdown_11a)
     ttk.Button(tab11, text='Set', command=change_dropdown_11a).grid(row=5, column=0, padx=8, pady=8)
 
-    if float(var_11a_text_choices[var_11a_text.get()]) != 1.0:
+    if var_11a_text.get() == 'select':
+        pass
+    elif float(var_11a_text_choices[var_11a_text.get()]) != 1.0:
         try:
 
             if float(amount_var11b.get()) < 0.1:
-- 
GitLab