how to create in python a gui that writes into file : <p>I have this code that creates a gui with value entry box. but how do I make the it write into file when I push the button?</p>

<pre><code>from tkinter import *
from tkinter import messagebox
from tkinter import simpledialog

msg = messagebox
sdg = simpledialog

root = Tk()
w = Label(root, text="My Program")
w.pack()

msg.showinfo("welcome", "hi. ")

name = sdg.askstring("Name", "What is you name?")
age = sdg.askinteger("Age", "How old are you?")
</code></pre>
