редактор кода на tkinter с диалоговым окном v2
from tkinter import Tk, filedialog, Label, Button, Text, END
def file_open():
global open_file
open_file = filedialog.askopenfilename(filetypes=(("Python files", "*.py"),("All files", "*.*")))
text.delete(1.0, END)
with open(open_file, 'r') as file:
text.insert(1.0, file.read())
window = Tk()
window.geometry("310x220")
label = Label(text="Откройте файл который вы хотите просмотреть")
label.pack()
text = Text(height=10)
text.pack()
def save_file():
with open(open_file, 'w') as file:
file.write(f"{text}")
button = Button(text="Открыть", command=file_open)
button2 = Button(text='Сохранить', command=save_file)
button.pack(pady=5, padx=5)
button2.pack(pady=5, padx=6)
window.mainloop()
(проблема) кнопка \сохранить\ не работает
помогите пожалуйста решить проблему
заранее спасибо