def on_close_criteria_box(self, dia):
        """
        Function called on close of change acceptance criteria dialog that
        writes new criteria to the hardrive and sets new criteria as GUI's
        current criteria.

        Parameters
        ----------
        dia : closed change criteria dialog
        """
        window_list_specimens = [
            'specimen_n', 'specimen_mad', 'specimen_dang', 'specimen_alpha95']
        window_list_samples = ['sample_n', 'sample_n_lines',
                               'sample_n_planes', 'sample_k', 'sample_r', 'sample_alpha95']
        window_list_sites = ['site_n', 'site_n_lines',
                             'site_n_planes', 'site_k', 'site_r', 'site_alpha95']
        demag_gui_supported_criteria = window_list_specimens + \
            window_list_samples+window_list_sites

        if self.data_model == 3:
            new_crits = []
            for crit in demag_gui_supported_criteria:
                new_crit = {}
                command = "dia.set_%s.GetValue()" % (crit)
                new_value = pmag.execute(command, dia=dia)
                if new_value == None or new_value == '':
                    continue
                d = findall(r"[-+]?\d*\.\d+|\d+", new_value)
                if len(d) > 0:
                    d = d[0]
                comp = new_value.strip(str(d))
                if comp == '':
                    comp = '>='
                if 'specimen' in crit:
                    col = "specimens."+map_magic.spec_magic2_2_magic3_map[crit]
                elif 'sample' in crit:
                    col = "samples."+map_magic.samp_magic2_2_magic3_map[crit]
                elif 'site' in crit:
                    col = "sites."+map_magic.site_magic2_2_magic3_map[crit]
                else:
                    print("no way this like is impossible")
                    continue
                new_crit['criterion'] = "ACCEPT"
                new_crit['criterion_value'] = d
                new_crit['criterion_operation'] = comp
                new_crit['table_column'] = col
                new_crit['citations'] = "This study"
                new_crit['description'] = ''
                new_crits.append(new_crit)
            cdf = DataFrame(new_crits)
            cdf = cdf.set_index("table_column")
            cdf["table_column"] = cdf.index
            cdf = cdf.reindex_axis(sorted(cdf.columns), axis=1)
            if 'criteria' not in self.con.tables:
                cols = ['criterion', 'criterion_value', 'criterion_operation',
                        'table_column', 'citations', 'description']
                self.con.add_empty_magic_table('criteria', col_names=cols)
            self.con.tables['criteria'].df = cdf
            self.con.tables['criteria'].write_magic_file(dir_path=self.WD)
        else:
            for crit in demag_gui_supported_criteria:
                command = "new_value=dia.set_%s.GetValue()" % (crit)
                exec(command)
                # empty box
                if new_value == "":
                    self.acceptance_criteria[crit]['value'] = -999
                    continue
                # box with no valid number
                try:
                    float(new_value)
                except:
                    self.show_crit_window_err_messege(crit)
                    continue
                self.acceptance_criteria[crit]['value'] = float(new_value)

            #  message dialog
            self.saved_dlg(message="changes saved to criteria")
            self.write_acceptance_criteria_to_file()
            dia.Destroy()
def on_close_criteria_box ( self , dia ) : window_list_specimens = [ 'specimen_n' , 'specimen_mad' , 'specimen_dang' , 'specimen_alpha95' ] window_list_samples = [ 'sample_n' , 'sample_n_lines' , 'sample_n_planes' , 'sample_k' , 'sample_r' , 'sample_alpha95' ] window_list_sites = [ 'site_n' , 'site_n_lines' , 'site_n_planes' , 'site_k' , 'site_r' , 'site_alpha95' ] demag_gui_supported_criteria = window_list_specimens + window_list_samples + window_list_sites if self . data_model == 3 : new_crits = [ ] for crit in demag_gui_supported_criteria : new_crit = { } command = "dia.set_%s.GetValue()" % ( crit ) new_value = pmag . execute ( command , dia = dia ) if new_value == None or new_value == '' : continue d = findall ( r"[-+]?\d*\.\d+|\d+" , new_value ) if len ( d ) > 0 : d = d [ 0 ] comp = new_value . strip ( str ( d ) ) if comp == '' : comp = '>=' if 'specimen' in crit : col = "specimens." + map_magic . spec_magic2_2_magic3_map [ crit ] elif 'sample' in crit : col = "samples." + map_magic . samp_magic2_2_magic3_map [ crit ] elif 'site' in crit : col = "sites." + map_magic . site_magic2_2_magic3_map [ crit ] else : print ( "no way this like is impossible" ) continue new_crit [ 'criterion' ] = "ACCEPT" new_crit [ 'criterion_value' ] = d new_crit [ 'criterion_operation' ] = comp new_crit [ 'table_column' ] = col new_crit [ 'citations' ] = "This study" new_crit [ 'description' ] = '' new_crits . append ( new_crit ) cdf = DataFrame ( new_crits ) cdf = cdf . set_index ( "table_column" ) cdf [ "table_column" ] = cdf . index cdf = cdf . reindex_axis ( sorted ( cdf . columns ) , axis = 1 ) if 'criteria' not in self . con . tables : cols = [ 'criterion' , 'criterion_value' , 'criterion_operation' , 'table_column' , 'citations' , 'description' ] self . con . add_empty_magic_table ( 'criteria' , col_names = cols ) self . con . tables [ 'criteria' ] . df = cdf self . con . tables [ 'criteria' ] . write_magic_file ( dir_path = self . WD ) else : for crit in demag_gui_supported_criteria : command = "new_value=dia.set_%s.GetValue()" % ( crit ) exec ( command ) if new_value == "" : self . acceptance_criteria [ crit ] [ 'value' ] = - 999 continue try : float ( new_value ) except : self . show_crit_window_err_messege ( crit ) continue self . acceptance_criteria [ crit ] [ 'value' ] = float ( new_value ) self . saved_dlg ( message = "changes saved to criteria" ) self . write_acceptance_criteria_to_file ( ) dia . Destroy ( )
Function called on close of change acceptance criteria dialog that
        writes new criteria to the hardrive and sets new criteria as GUI's
        current criteria.

        Parameters
        ----------
        dia : closed change criteria dialog