код на python 3.7
import tkinter from tkinter.filedialog import asksaveasfile, askopenfile from tkinter.messagebox import showerror import easygui FILE_NAME = tkinter.NONE def credit(): easygui.msgbox( " You can save files with buttons Save and Save As \n You can open files with button Open \n You can create new file with button New File") def new_file(): global FILE_NAME FILE_NAME = "Untitled" text.delete('1.0', tkinter.END) def save_file(): data = text.get('1.0', tkinter.END) out = open(FILE_NAME, 'w') out.write(data) out.close() def save_as(): out = asksaveasfile(mode='w', defaultextension='.txt') data = text.get('1.0', tkinter.END) try: out.write(data.rstrip()) except Exception: showerror(title="Oops!", message="Unable to save file....") def open_file(): global FILE_NAME inp = askopenfile(mode="r") if inp is None: return FILE_NAME = inp.name data = inp.read() text.delete('1.0', tkinter.END) text.insert('1.0', data) root = tkinter.Tk() root.title("2Text") root.geometry("600x400") root.minsize(width=600, height=400) menuBar = tkinter.Menu(root) fileMenu = tkinter.Menu(menuBar) menuBar.add_command(label="New", command=new_file) menuBar.add_command(label="Open", command=open_file) menuBar.add_command(label="Save", command=save_file) menuBar.add_command(label="Save As", command=save_as) menuBar.add_command(label="Exit", command=root.quit) menuBar.add_command(label="Credits & Info", command=credit) root.config(menu=menuBar) text = tkinter.Text(root, width=400, height=400) text.pack() root.mainloop()