title: How should I read and write a configuration file for TkInter?
body: <p>I've gathered numbers in a configuration file, and I would like to apply them to buttons. Clicking the button should allow the number to be changed and then re-written to the config file. My current code is as follows:</p>
  
  <pre><code>from tkinter import*
  import tkinter as tk
  import tkinter.simpledialog
  
  def onChange(i):     
      btn_list[i].config(text='Updating...',bg='red')  
      btn_list[i].grid(in_=root,row=rw[i],column=2)
      ans=tk.simpledialog.askfloat('Updating....', 'What is the current price?')
      if ans:
          btn_list[i].config(text='RM {:,.2f}'.format(ans))
          btn_list[i].config(bg='yellow')
          c=str(ans)
          fw=open('dataUpdate.txt','w')
          fw.write(c)
          fw.close()
  
  root=Tk()
  
  Title=['Item','Unit','Price']
  Item=['Kopi O','Teh O','Teh Tarik']
  Unit= '1 cup'
  cl=[0,1,2]
  rw=[1,2,3]
  btn_list=[]
  fr=open('dataUpdate.txt','r')
  
  with open('dataUpdate.txt') as input_file:
      text=input_file.read()
      strings=text.split()
      number=[float(item) for item in strings]
      print(number)
      fr.close()
  
  for k in range(3):
      btnT1=tk.Button(root,text=Title[k],width=12,bg='light green')
      btnT1.grid(in_=root,row=0,column=cl[k])
  
  for x in range(3):
      btnT2=tk.Button(root,text=Item[x],width=12)
      btnT2.grid(in_=root,row=rw[x],column=0)
  
  for y in range(3):
      btnT3=tk.Button(root,text=Unit,width=12)
      btnT3.grid(in_=root,row=rw[y],column=1)             
  
  for z in range(3):
      btnT4=tk.Button(root,text=('RM {:,.2f}'.format(number[z])),bg='yellow',width=12,\
                  command=lambda i=z:onChange(i))
      btnT4.grid(in_=root,row=rw[z],column=2)
      btn_list.append(btnT4)
  
  root.mainloop()
  </code></pre>
  
  <p>Here's a screenshot of my basic configuration file:
  <a href="https://i.stack.imgur.com/Cwl4z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cwl4z.png" alt="dataUpdate.txt"></a></p>