def open_file_dialog(): """Открывает диалоговое окно выбора имени файла и вызывает функцию считывания параметров системы небесных тел из данного файла. Считанные объекты сохраняются в глобальный список space_objects """ global space_objects global perform_execution global Scale perform_execution = False for obj in space_objects: space.delete(obj.image) # удаление старых изображений планет in_filename = tkinter.filedialog.askopenfilename(filetypes=(("Text file", ".txt"),)) space_objects = solar_input.read_space_objects_data_from_file(in_filename) max_distance = max([max(abs(obj.x), abs(obj.y)) for obj in space_objects]) Scale = solar_vis.calculate_scale_factor(max_distance) for obj in space_objects: if obj.type == 'Star': solar_vis.create_star_image(space, obj) elif obj.type == 'Planet': solar_vis.create_planet_image(space, obj) else: print(obj.type) raise AssertionError() filel = open("Test.txt", "w") filel.close()
def draw_planets(): for obj in space_objects: if obj.type == 'star': fix_color(obj) create_star_image(screen, obj) elif obj.type == 'planet': fix_color(obj) create_planet_image(screen, obj) else: raise AssertionError()
def open_file_dialog(): """Открывает диалоговое окно выбора имени файла и вызывает функцию считывания параметров системы небесных тел из данного файла. Считанные объекты сохраняются в глобальный список space_objects """ global space_objects global perform_execution perform_execution = False for obj in space_objects: space.delete(obj.image) # удаление старых изображений планет in_filename = fd.askopenfilename(filetypes=(("Text file", ".txt"), )) space_objects = si.read_space_objects_data_from_file(in_filename) max_distance = max([max(abs(obj.x), abs(obj.y)) for obj in space_objects]) sv.calculate_scale_factor(max_distance) for obj in space_objects: if obj.type == 'star': sv.create_star_image(space, obj) elif obj.type == 'planet': sv.create_planet_image(space, obj) else: raise AssertionError() sv.update_system_name(space, in_filename)