Beispiel #1
0
 def file_loaded(name, new):
     """Register an event to save contents when a file has been uploaded."""
     i = int(name.split("_")[1])
     fname = file_widget.filenames[i]
     index = self.model.file_names.index(fname)
     len_files = len(self.model.file_names)
     fpath = os.path.join("./moldata", fname)
     with open(fpath, "w") as f:
         f.write(new)
     geom = getxyz(fpath)
     atom_count = {}
     heaviest = 1
     for i, line in enumerate(geom):
         anum = int(line[0])
         heaviest = max(anum, heaviest)
         symbol = ELEMENTS[anum].symbol
         if symbol in atom_count.keys():
             atom_count[symbol].append(i + 1)
         else:
             atom_count[symbol] = [i + 1]
     self.model.atom_counts[fname] = atom_count
     counter = 1000
     while counter:
         if len(upload_area.children) == len_files:
             element_picker = upload_area.children[index].children[0]
             element_picker.options = list(atom_count.keys())
             element_picker.value = ELEMENTS[heaviest].symbol
             return None
         else:
             counter -= 1
             sleep(0.005)
     print("fileLoadError:", fname, flush=True)
Beispiel #2
0
 def geom(self):
     return icosaio.getxyz(self.path)