def insert_text(event):
file_name = fd.askopenfilename()
if file_name:
with open(file_name) as f:
s = f.read()
text.insert(1.0, s)
def extract_text(event):
file_name = fd.asksaveasfilename(filetypes=(('mmm files', '*.mmm',),))
if file_name:
with open(file_name, 'w') as f:
s = text.get(1.0, tk.END)
f.write(s)
if __name__ == '__main__':
root = tk.Tk()
root.title('test')
root.state('zoomed')
root.bind('<Control-o>', insert_text)
root.bind('<Control-s>', extract_text)
text = tk.Text(width=50, height=25)
text.grid(columnspan=2)
root.mainloop()