Edit this code on Python:
import tkinter as tk
from tkinter import *
from tkinter import filedialog

class Student:
    def __init__(self, group_num, name, phone, email):
        self.group_num = group_num
        self.name = name
        self.phone = phone
        self.email = email

class AddStudentWindow(tk.Toplevel):
    def __init__(self, parent, app):
        super().__init__(parent)
        self.title("Добавить студента")
        self.parent = parent
        self.app = app

        tk.Label(self, text="Номер группы:").grid(row=0, column=0)
        self.group_num_entry = tk.Entry(self, bd=2)
        self.group_num_entry.grid(row=0, column=1)

        tk.Label(self, text="ФИО студента:").grid(row=1, column=0)
        self.name_entry = tk.Entry(self, bd=2)
        self.name_entry.grid(row=1, column=1)

        tk.Label(self, text="Номер телефона:").grid(row=2, column=0)
        self.phone_entry = tk.Entry(self, bd=2)
        self.phone_entry.grid(row=2, column=1)

        tk.Label(self, text="Адрес эл. почты:").grid(row=3, column=0)
        self.email_entry = tk.Entry(self, bd=2)
        self.email_entry.grid(row=3, column=1)

        tk.Button(self, text="Добавить", command=self.add_student).grid(row=4, column=0, columnspan=2)

    def add_student(self):
        group_num = self.group_num_entry.get()
        name = self.name_entry.get()
        phone = self.phone_entry.get()
        email = self.email_entry.get()
        student = Student(group_num=group_num, name=name, phone=phone, email=email)
        self.app.students.append(student)
        self.app.update_listbox()
        self.destroy()

class EditStudentWindow(tk.Toplevel):
    def __init__(self, parent, app, index):
        super().__init__(parent)
        self.title("Редактировать студента")
        self.parent = parent
        self.app = app
        self.index = index
        self.student = self.app.students[index]

        tk.Label(self, text="Номер группы:").grid(row=0, column=0)
        self.group_num_entry = tk.Entry(self, bd=2)
        self.group_num_entry.grid(row=0, column=1)
        self.group_num_entry.insert(tk.END, self.student.group_num)

        tk.Label(self, text="ФИО студента:").grid(row=1, column=0)
        self.name_entry = tk.Entry(self, bd=2)
        self.name_entry.grid(row=1, column=1)
        self.name_entry.insert(tk.END, self.student.name)

        tk.Label(self, text="Номер телефона:").grid(row=2, column=0)
        self.phone_entry = tk.Entry(self, bd=2)
        self.phone_entry.grid(row=2, column=1)
        self.phone_entry.insert(tk.END, self.student.phone)

        tk.Label(self, text="Адрес эл. почты:").grid(row=3, column=0)
        self.email_entry = tk.Entry(self, bd=2)
        self.email_entry.grid(row=3, column=1)
        self.email_entry.insert(tk.END, self.student.email)

        tk.Button(self, text="Сохранить", command=self.save_student).grid(row=4, column=0, columnspan=2)

    def save_student(self):
        group_num = self.group_num_entry.get()
        name = self.name_entry.get()
        phone = self.phone_entry.get()
        email = self.email_entry.get()

        self.app.students[self.index].group_num = group_num
        self.app.students[self.index].name = name
        self.app.students[self.index].phone = phone
        self.app.students[self.index].email = email

        self.app.update_listbox()
        self.destroy()

    class App(tk.Frame):
        def __init__(self, master=None):
            super().__init__(master)
            self.master = master
            self.master.title("Студенты группы")
            self.create_widgets()

        def create_widgets(self):
            self.listbox = tk.Listbox(self.master)
            self.listbox.pack(fill=tk.BOTH, expand=True)
            self.listbox.config(yscrollcommand=Scrollbar().set)

            self.add_button = tk.Button(self.master, text="Добавить студента", command=self.add_student)
            self.add_button.pack()

            self.edit_button = tk.Button(self.master, text="Редактировать студента", command=self.edit_student)
            self.edit_button.pack()

            self.clear_button = tk.Button(self.master, text="Очистить список", command=self.clear_list)
            self.clear_button.pack()

        def add_student(self):
            add_window = AddStudentWindow(self.master, self)
            add_window.grab_set()

        def edit_student(self):
            try:
                index = self.listbox.curselection()[0]
                edit_window = EditStudentWindow(self.master, self, index)
                edit_window.grab_set()
            except:
                pass

        def clear_list(self):
            self.students = []
            self.update_listbox()

        def update_listbox(self):
            self.listbox.delete(0, tk.END)
            for student in self.students:
                self.listbox.insert(tk.END, student.name + " - " + student.group_num)

    class App(tk.Frame):
        def __init__(self, master=None):
            super().__init__(master)
            self.master = master
            self.master.title("Студенты группы")
            self.create_widgets()

        def create_widgets(self):
            self.listbox = tk.Listbox(self.master)
            self.listbox.pack(fill=tk.BOTH, expand=True)

            self.search_label = tk.Label(self.master, text="Поиск студента:")
            self.search_label.pack(side=tk.LEFT)
            self.search_entry = tk.Entry(self.master)
            self.search_entry.pack(side=tk.LEFT, padx=5)

            self.search_button = tk.Button(self.master, text="Найти", command=self.search_student)
            self.search_button.pack(side=tk.LEFT)

            self.delete_button = tk.Button(self.master, text="Удалить выделенного студента",
                                           command=self.delete_student)
            self.delete_button.pack()

            self.select_file_button = tk.Button(self.master, text="Выбрать файл", command=self.select_file)
            self.select_file_button.pack(side=tk.LEFT)

            self.save_button = tk.Button(self.master, text="Сохранить в файл", command=self.save_to_file)
            self.save_button.pack(side=tk.LEFT)

            self.add_button = tk.Button(self.master, text="Добавить студента", command=self.add_student)
            self.add_button.pack()

            self.edit_button = tk.Button(self.master, text="Редактировать студента", command=self.edit_student)
            self.edit_button.pack()

            self.clear_button = tk.Button(self.master, text="Очистить список", command=self.clear_list)
            self.clear_button.pack()

            self.students = []

        def add_student(self):
            AddStudentWindow(self.master, self)

        def clear_list(self):
            self.students = []
            self.update_listbox()

        # функция выбора файла для импорта
        def select_file(self):
            filename = filedialog.askopenfilename(defaultextension='.txt')
            if filename:
                with open(filename, 'r') as file:
                    content = file.read()
                    self.students = content.split('\n')
                    self.update_listbox()

        # функция сохранения данных в файл
        def save_to_file(self):
            filename = filedialog.asksaveasfilename(defaultextension=".txt",
                                                    filetypes=(("Text File", "*.txt"), ("All Files", "*.*")))
            if filename:
                with open(filename, "w") as outfile:
                    outfile.write('\n'.join(self.students))

        def update_listbox(self):
            self.listbox.delete(0, tk.END)
            for i, student in enumerate(self.students):
                self.listbox.insert(tk.END, f"{i}. {student}")

        def search_student(self):
            query = self.search_entry.get()
            results = []
            for student

root = tk.Tk()
root.title("Студенты группы")
app = App(master=root)
app.pack(fill=tk.BOTH, expand=True)
app.mainloop()