from tkinter import *
root = Tk()
root.geometry("600x420")
text = Text(font=["Consolas",10])
text.pack()
def w():
print(text.get("1.0",END))
f = open("xd.txt","w")
f.write(text.get("1.0",END))
f.close()
btn = Button(text="WRITE",command=w)
btn.pack()
root.mainloop()
import tkinter.font as tkfont
font = tkfont.Font(font=text['font'])
tab_size = font.measure(' '*4)
# и установить размер табов
text.config(tabs=tab_size)