def launch(__self__, __input__=None): global DETECTOR if not DETECTOR.Configured: messagebox.showerror( "Detector not configured!", "SDD Detector parameters are not configured!") return if __input__ is not None: input_file, output_file = __input__, __self__.out exe_str = r"xrmc {}".format(input_file) print("SIMULATION START!") p1 = subprocess.Popen( exe_str, stderr=subprocess.PIPE) #, stdout=subprocess.PIPE) p1.wait() print("SIMULATION DONE") for file_ in __self__.temp: os.remove(file_) print(f"Removed {file_}") else: compounds, materials, thicknesses = [], [], [] skipped_materials, skipped_thick = [], [] for i in range(len(__self__.layers)): if __self__.layers[i].get() \ and __self__.layers[i].get() != "Custom"\ and __self__.thicknesses[i].get() > 0.0: materials.append(__self__.layers[i].get()) thicknesses.append(__self__.thicknesses[i].get()) else: skipped_materials.append(__self__.layers[i].get()) skipped_thick.append(i) if skipped_materials != []: text1 = "" for mat, l in zip(skipped_materials, skipped_thick): if mat == "": mat = "Empty" text1 = str(mat) + f" - Layer {l}" messagebox.showinfo("Invalid layers!", f"Ignoring layers: {text1}") for material in materials: a = Elements.compound() a.set_compound(material) compounds.append(a) pars = Configure.Parser() pars.get_planes(thicknesses) input_file, output_file = pars.write_inputs(compounds) exe_str = r"xrmc {}".format(input_file) print("SIMULATION START!") p1 = subprocess.Popen( exe_str, stderr=subprocess.PIPE) #, stdout=subprocess.PIPE) p1.wait() print("SIMULATION DONE") if __self__.EraseVar.get(): for f in pars.temporary_files: try: os.remove(f) print(f"Got rid of {f}") except: print(f"Could not remove {f}!") print("Output file: ", output_file) load_dat(output_file=output_file) return