I need to copy this file to this text widget, and I don't understand why my text widget is NoneType object?
import tkinter
from tkinter import filedialog as fd
class word_example(tkinter.Frame):
def __init__(self, parent):
tkinter.Frame.__init__(self, parent)
self.parent = parent
self.parent.configure(background='#838B8E')
self.parent.geometry("950x680+190+50")
self.parent.title("Changer")
self.set_all()
def set_all(self):
self.change_with = tkinter.Entry(self.parent, width=25).place(x = 120, y = 50)
self.change_with_label = tkinter.Label(self.parent, text="Change with: ",
width=12, height=2).place(x=20, y=40)
self.change_to = tkinter.Entry(self.parent, width=25).place(x=120, y=120)
self.change_to_label = tkinter.Label(self.parent, text="Change to: ",
width=12, height=2).place(x=20, y=110)
self.open_file_butt = tkinter.Button(self.parent, text="Open file",
command=self.upload_file).place(x=52, y=175)
self.start_file_text = tkinter.Text(self.parent, width=115, height=28).place(x=11, y=220)
self.file_safe_option_label = tkinter.Label(self.parent, text="Safe method: ",
width=12, height=2).place(x=320, y=40)
self.v = tkinter.IntVar()
self.file_safe_option_1 = tkinter.Radiobutton(self.parent, variable=self.v, value=0,
text="Rewrite file", height=2, width=11)
self.file_safe_option_2 = tkinter.Radiobutton(self.parent, variable=self.v, value=1,
text="Make new file", height=2, width=11)
self.file_safe_option_1.place(x=450, y=40)
self.file_safe_option_2.place(x=450, y=80)
self.run_but = tkinter.Button(text="Run", background="#62C13F", foreground="#272727",
width=6, height=2, font=38).place(x=830, y=150)
def upload_file(self):
self.num_file = 0
self.file_name = fd.askopenfilename()
with open(self.file_name, "r") as main_text_file:
for line in main_text_file:
self.formated_line = f"{line}\n"
self.start_file_text.insert(self.num_file, self.formated_line)
self.num_file += 1
def main():
window = tkinter.Tk()
word_example(window)
window.mainloop()
if __name__ == "__main__":
main()
What did I do wrong?