title: Writing variables from GUI to text file in tkinter
body: <p>I'm trying to write the text fields values to a file like this (where inputtxt is a Text widget):</p>
  <pre><code>    input_file_name =   inputtxt1.get('1.0', 'end-1c').replace(&quot; &quot;,&quot;&quot;)
      num_of_compare_points = inputtxt2.get('1.0','end-1c')
      VER = inputtxt3.get('1.0','end-1c')
      mode = inputtxt4.get(1.0','end-1c')
      executionMode = inputtxt5.get('1.0','end-1c')
      numOfWorkers = inputtxt6.get ('1.0','end-1c')
      sessionFile = inputtxt7.get('1.0','end-1c')
  
      file = open(&quot;file_1.setup&quot;,&quot;w&quot;)
           file.write (input_file_name + &quot;\n&quot; + num_of_compare_points + &quot;\n&quot; +    Option+&quot;\n&quot;+VER+&quot;\n&quot;+mode+&quot;\n&quot;+executionMode+&quot;\n&quot;+numOfWorkers+&quot;\n&quot;+sessionFile)
  </code></pre>
  <p>This method was good but I want to write the variable name +the value to the file so that the user can fill the values from the file not only through GUI and the order in file will be irrelevant since we're storing in the variable itself   , Example:
  File_1.setup:
  input_file_name = (some name the user can change it from here not from GUI)
  num_of_compare_points = (some number the user can change it from here not from GUI)
  .
  .
  .
  etc
  <strong>UPDATE: I'm using the file attribute:value in a restore finction which put the value of each attribute on its related text field ; the problem here that I have only the value but not the variable:value and the variables must be in order (I need the order to be irrelevent since I'll use the variable name)</strong></p>
  <pre><code>def restore_info():
  
  if os.stat('file_1.setup').st_size == 0:
      print(&quot;Writing to setup file..&quot;)
  else:
      with open('file_1.setup','r') as f:
      
              lines = list(line for line in (l.strip() for l in f) if line)
      x = len(lines)
      print (x)
      for i in lines:
          print (i)                   
      if (x==7):
          inputtxt1.insert('end',lines[0])
          inputtxt2.insert('end',lines[1])
          inputtxt3.insert['end',lines[2])
          ... etc
  </code></pre>
  <p><strong>UPDATE2 : I've managed to split each line based on &quot;:&quot; but I need a way to tell the program where is variable and where is value</strong></p>
  <pre><code>def restore_info():
  
  if os.stat('file_1.setup').st_size == 0:
      print(&quot;Writing to setup file..&quot;)
  else:
      with open('file_1.setup','r') as f:
      
              lines = list(line for line in (l.strip() for l in f) if line)
      x = len(lines)
      print (x)
      for i in lines:
          splitted_i=i.split(&quot;:&quot;)
          print (splitted_i)
  </code></pre>
  <p>UPDATE 3:Advantage of this step</p>
  <ol>
  <li>User will be able to apply the value manually, and not only through GUI.</li>
  <li>The order will be irrelevant.</li>
  <li>Any amount of spaces should be allowed around and in between the variable name and its value.</li>
  <li>It will be very easy to search file_1.setup and extract the value for each field.</li>
  </ol>