AttributeError: Экземпляр PageOne не имеет атрибута «delete» - PullRequest
2 голосов
/ 19 октября 2019

Я пытаюсь проверить входной файл CSV, чтобы убедиться, что пользователь вводит правильный файл CSV. Однако я продолжал получать сообщение об ошибке AttributeError: PageOne instance has no attribute 'delete'. Я не могу понять, почему.

В настоящее время, когда я ввожу правильный / неправильный файл CSV, появится всплывающее окно, чтобы сказать мне, если я ввел правильный файл или нет, но код будетне продолжать до file_entry.delete(0, tk.END) и появляется ошибка AttributeError: PageOne instance has no attribute 'delete'.

Ниже приведены мои коды для моего кадра Tkinter и функции проверки.

class PageOne(tk.Frame):

    def get_procurement_file(file_entry):
        file_name = fd.askopenfilename(title="Select file", filetypes=(("CSV Files", "*.csv"),))
        entry_file = file_name.split("/")[-1]
        if entry_file == "government-procurement-via-gebiz.csv":
            file_entry.popup_successinfo()
            file_entry.delete(0, tk.END)
            file_entry.insert(0, entry_file)
        else:
            file_entry.popup_errorinfo()
            file_entry.delete(0, tk.END)
        # file_entry.delete(0,END)
        # file_entry.insert(0,file_name)

    def get_contractor_file(file_entry):
        file_name = fd.askopenfilename(title="Select file", filetypes=(("CSV Files", "*.csv"),))
        entry_file = file_name.split("/")[-1]
        if entry_file == "listing-of-registered-contractors.csv":
            file_entry.popup_successinfo()
            file_entry.delete(0, tk.END)
            file_entry.insert(0, entry_file)
        else:
            file_entry.popup_errorinfo()
            file_entry.delete(0, tk.END)
        # file_entry.delete(0,END)
        # file_entry.insert(0,file_name)

    def popup_successinfo(self):
        showinfo("Window", "Successfully input!")

    def popup_errorinfo(self):
        showinfo("Window", "Wrong input! Please insert the Correct File!")

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller

        self.entry_csv = tk.Entry(self, text="", width=80, font=20)
        self.entry_csv.place(x=250, y=380)
        self.entry_csv2 = tk.Entry(self, text="", width=80, font=20)
        self.entry_csv2.place(x=250, y=500)

        self.label = tk.Label(self, bg="#64dd17", height=10, font=30, text="1002 Dataset Analyzer")
        self.label.pack(fill="x")

        self.label = tk.Label(self, text="1st Dataset File: ", font=30)
        self.label.place(x=100, y=380)

        self.button = tk.Button(self, text="Browse...", width=10, height=2, command=lambda: self.get_procurement_file())
        self.button.place(x=1000, y=370)

        self.label = tk.Label(self, text="2nd Dataset File:", font=30)
        self.label.place(x=100, y=500)

        self.button = tk.Button(self, text="Browse...", width=10, height=2, command=lambda: self.get_contractor_file())
        self.button.place(x=1000, y=490)

        self.button = tk.Button(self, text="Upload", command=lambda: controller.show_frame("PageTwo"), width=10, height=2)
        self.button.place(x=1250, y=430)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...