title: How do I get tkinter application to update as I change a text file needed?
body: <p>I have a text file with values that I need to display in a scroll box tkinter. I have been succesful in doing this but there is a problem. When I press submit to add more values to my text file in my program, the scrollbox displaying the contents in the text file does not update with the new values.</p>
  <p>Here is a screenshot of the program:
  <a href="https://i.stack.imgur.com/fIiue.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fIiue.png" alt="Here is a screenshot of the program:" /></a></p>
  <p>This is my text file:</p>
  <pre><code>amazon.com
  username@gmail.com
  n3*F/X&quot;qse~a`_+
  
  netflix.com
  username@outlook.com
  avOmCl|Jb?O&lt;
  
  apple.com
  username@icloud.com
  s=DT8n*Y&quot;y
  </code></pre>
  <p>However when I press submit the text file updates with the values submitted but the scrollbox does not.</p>
  <p>Here is my full code:</p>
  <pre><code>import string
  import random
  from tkinter import * 
  import tkinter.scrolledtext as st 
  
  mypasslist = []
  
  with open(&quot;password&amp;usernames.txt&quot;, &quot;r&quot;) as input:
      for line in input:
          items = line.split()
          mypasslist.append([item for item in items[0:]])
  
  
  def generatePassword():
      characters = string.ascii_letters + string.punctuation  + string.digits
      password =  &quot;&quot;.join(random.choice(characters) for x in range(random.randint(8, 16)))
      return password
  
  def writeToFile(input_variable):
      with open(&quot;password&amp;usernames.txt&quot;, &quot;a&quot;) as input:
          input.writelines(input_variable)
  
  top = Tk()    
  top.geometry(&quot;1920x1080&quot;)   
  
  def ifSubmit():
      global a
      a = generatePassword()
      label1 = Label(top, text='Your password is: %s' % a, font=(&quot;Arial&quot;, 11)).place(x = 40, y = 170)
      label1 = Label(top, justify='left', text='Your password and username has been saved, you can access them below.').place(x = 40, y = 227)
      copy_button = Button(top, text = 'Copy', command=copyText).place(x=40, y=195)
      
      service = service_var.get()
      username = username_var.get()
  
      writeToFile('%s\n' % str(service))
      writeToFile('%s\n' % str(username))
      writeToFile('%s\n' % str(a))
      writeToFile('\n')
  
  def copyText():
      top.clipboard_clear()
      top.clipboard_append(a)
      top.update()
  
  # the label for user_name  
  Service = Label(top, text = &quot;Service&quot;).place(x = 40, y = 60)   
  user_name = Label(top, text = &quot;Username&quot;).place(x = 40, y = 100)   
  
  submit_button = Button(top, text = &quot;Submit&quot;, command=ifSubmit)
  submit_button.place(x = 40, y = 130)
  
  service_var = StringVar()
  Service_input_area = Entry(top, width = 30, textvariable=service_var)
  Service_input_area.place(x = 110, y = 60)
  service = service_var.get()
  
  username_var = StringVar()
  user_name_input_area = Entry(top, width = 30, textvariable=username_var)
  username = username_var.get()
  user_name_input_area.place(x = 110, y = 100)
  
  text_area = st.ScrolledText(top, width = 50, height = 10) 
    
  text_area.grid(column = 0, pady = 260, padx = 40) 
  
  for i in mypasslist:
      text_area.insert(INSERT, i)
      text_area.insert(INSERT, '\n')
  
  text_area.configure(state ='disabled') 
  
  top.mainloop()
  </code></pre>
  <p>So how could I make the program update every time new values have been submitted?</p>