How to use tkinter .Text to create a large text box with that will export entry to .txt file [duplicate]

  python, tkinter, tkinter-entry, tkinter-layout

I want to create a script that will let users type an entry into a box and whatever they wrote will be submitted and saved in a separate text file. Im stuck on it being a single-line entry. This is my code so far:

import tkinter as tk

from tkinter import Entry


def save():
file_name = text.get()
with open('consultant.txt', 'w') as file_object:
file_object.write(file_name)  

if __name__ == '__main__':
root = tk.Tk()
root.title("TextTool")
root.geometry("400x400")
entry_field_variable = tk.StringVar()
text = tk.Entry(root, textvariable=entry_field_variable)
text.pack()

tk.Button(root, text="save", command=save).pack()

root.mainloop()

Source: Python Questions

LEAVE A COMMENT