title: How to save data so that is is still there after you close and reopen tkinter application?
body: <p>I have created a simple application where you can enter a word and press a <kbd>button</kbd>, and each time you press the <kbd>button</kbd>, an image and 2 labels are packed onto the screen, 1 label containing the words you have typed. I want to make it so that if you close the application and reopen it, the images and labels you have placed by pressing the button are still there. How could this be done?</p>
  <pre><code>from tkinter import *
  import pickle
  import calendar
  from tkcalendar import *
  
  import calendar
  
  from tkcalendar import *
  from datetime import datetime
  from datetime import date
  from time import strftime
  from datetime import timedelta, datetime, date
  from ttkthemes import ThemedTk, THEMES
  import pickle
  
  self = Tk()
  self.title('Storing data')
  self.geometry(&quot;850x800&quot;)
  
  x = 200
  y = 250
  c = 460
  d = 290
  e = 325
  f = 355
  g = 390
  h = 420
  i = 460
  j = 490
  
  LARGE_FONT= (&quot;Verdana&quot;, 24)
  SMALL_FONT=(&quot;Verdana&quot;, 12)
  
  
  def get_text(file):
      with open(file, &quot;r&quot;) as MyFile:
          return MyFile.read()
  
  
  def edit_text(file, text, img_dir):
      with open(file, &quot;w&quot;) as MyFile:
          MyFile.write(text + &quot;\n&quot; + &quot;apple.png&quot;)
  
  
  def step(self):
      my_progress['value']+= 5
          
  
  def display():
  
      global x , y , c , d , e , f , g, h, i, j
      box_image = PhotoImage(file='apple.png')
      panel2 = Label(self, image=box_image, bg='#f7f6f6')
      panel2.image = box_image
      panel2.place(x=x, y=y)
      x=x
      y = y+260
      #assessment name
      n = Label(self, text=&quot;&quot;, bg=&quot;#e0f6fc&quot;, font=60)
      
      n.configure(text=assessment_name.get())
      n.pack()
      
      #due date
      d = Label(self, text=&quot;Due:&quot;, bg=&quot;#e0f6fc&quot;, font=SMALL_FONT)
      d.pack()
      #cal date
      c= Label(self, text=&quot;&quot;, bg=&quot;#e0f6fc&quot;, font=SMALL_FONT)
      c.pack()
          
      
  button = Button(self, text=&quot;place&quot;, command=display)
  button.pack()
  
  save = Button(self, text=&quot;save&quot;, command=edit_text)
  save.pack()
  
  open_button =Button(self, text=&quot;open&quot;, command=get_text)
  open_button.pack()
  
  
  edit_text(&quot;textfile.txt&quot;, &quot;label contents&quot;, &quot;apple.png&quot;)
  
  
  
    
  
  assessment_name = Entry(self)
  assessment_name.place(relx=0.5, y=220, anchor='center')
  
  global cal2
  cal2 = Calendar(self, background=&quot;#e0f6fc&quot;, disabledbackground=&quot;white&quot;, bordercolor=&quot;light blue&quot;, headersbackground=&quot;light blue&quot;, normalbackground=&quot;#e0f6fc&quot;, foreground=&quot;black&quot;, normalforeground='black', headersforeground='white', selectmode=&quot;day&quot;, year=2021, month=8, day=9)
  cal2.place(relx=0.5, y=400, anchor='center')
  
  due_date = Button(self, text=&quot;Submit&quot;)
  due_date.place(relx=0.5, y=510, anchor='center')
  
  
  
  
  
  
  
  self.mainloop()
  </code></pre>