title: tkinter - Printing current input + by mistake also previous inputs
body: <p>I am making a GUI in Tkinter and the code prints some attributes of a class.
  However, something makes it print the attributes from the current instance but also from the previous ones (sorry if the jargon is wrong, I'm really new to this).</p>
  <p>So in the Todo-list GUI I have created, I will enter a task and specify some attributes, then print all the attributes.
  The task name is then displayed in a listbox and all the attributes of the task should be printed to terminal at the same time - however, this is where it will print the current attributes which I have just entered but also the attributes from the previously added task.</p>
  <p>This is the code and the <code>print</code> command is in the <code>def show_task():</code> function.</p>
  <pre><code>from tkcalendar import * # Calendar module
  import tkinter.messagebox # Import the messagebox module
  
  task_list = []
  task_types = ['Sparetime', 'School', 'Work']
  
  class Task:
      def __init__(self, n, type_, i, m, p, h): #(h, w=8, p, u, n, v):
          self.name = n
          self.type = type_
          self.impact = i
          self.manageability = m
          self.proximity = p
          self.hours = h
          #self.connectivity = c
          ##self.work = w ##hours of work per day
          ##self.urgency = u
          ##self.note = n
          ##self.value = v
  
  def show_tasks():
     # for widget in task_frame.winfo_children():
         # widget.destroy()
  
      for task in task_list:
          #listbox_tasks.insert(tkinter.END, *task_list) #(task_frame, text=f'{task.name} \n Type: {task.type} | Impact: {task.impact}| Manageability: {task.manageability} | Proximity: {task.proximity}').pack(fill='x')  
          print(
              'Task:'+task.name +
              '\n' +
              'Type:' + task.type + '\n' +
              'Impact:' + task.impact + '\n' +
              'Manageability:' + task.manageability + '\n' +
              'Proximity(Deadline):' + task.proximity + '\n' +
              'Hours:' + task.hours + '\n'
              )
  
  def open_add_task():
      taskwin = Toplevel(root)
      taskwin.focus_force()
      
      #TITLE
      titlelabel = Label(taskwin, text='Title task concisely:').grid(column=1, row=0)
      name_entry = Entry(taskwin, width=40, justify='center')
      name_entry.grid(column=1, row=1)
  
      #TYPE
      typelabel = Label(taskwin, text='Type').grid(column=0, row=2)
      type_var = StringVar(value=task_types[2])
      OptionMenu(taskwin, type_var, *task_types).grid(column=0, row=3, sticky='nsew')
  
      #IMPACT
      impactlabel = Label(taskwin, text='Impact').grid(column=1, row=2)
      imp_var = StringVar(value=0)
      OptionMenu(taskwin, imp_var, *range(0, 10+1)).grid(column=1, row=3, sticky='ns')
  
      #MANAGEABILITY
      manlabel = Label(taskwin, text='Manageability').grid(column=2, row=2)
      man_var = StringVar(value=0)
      OptionMenu(taskwin, man_var, *range(0, 10+1)).grid(column=2, row=3, sticky='nsew')
  
      #PROXIMITY
      proximity_label = Label(taskwin, text = 'Choose a deadline', justify='center')
      proximity_label.grid(column=1, row=4)
      cal = Calendar(taskwin, selectmode='day', year=2021, month=4, day=27)
      cal.grid(column=1, row=5)
      def get_date():
          proximity_output_date.config(text=cal.get_date()) ##the .config didn't work until i did .grid(column=, row=) on seperate lines
  
  
  
      #HOURS(required)
      hourlabel = Label(taskwin, text='Whole hours \n required').grid(column=1, row=16)
      hour_entry = Entry(taskwin, width=4, justify='center')
      hour_entry.grid(column=1, row=17)
  
      def add_task():
          if name_entry.get() != '': # If textbox inputfield is NOT empty do this:
              task_list.append(Task(name_entry.get(), type_var.get(), imp_var.get(), man_var.get(), cal.get_date(), hour_entry.get()))
              show_tasks()
              listbox_tasks.insert(tkinter.END, name_entry.get())
              name_entry.delete(0, tkinter.END)
              taskwin.destroy()
          else:
              tkinter.messagebox.showwarning(title='Whoops', message='You must enter a task')
          
      next_button = Button(taskwin, text='Next', command=add_task).grid(column=2, row=18, sticky='ew')
      
  
  def sort_tasks():
      pass
  def delete_task():
      pass
      #try:
          #task_index = listbox_tasks.curselection()[0]
          #listbox_tasks.delete(task_index)
      #except:
          #tkinter.messagebox.showwarning(title='Oops', message='You must select a task to delete')
  
  def save_tasks():
      pass
      #tasks = listbox_tasks.get(0, listbox_tasks.size())
      #pickle.dump(tasks, open('tasks.dat', 'wb'))
      
  
  
      
      
      
      
  
  root = Tk()
  
  
  
  
  
  
  
  
  task_frame = Frame()
  # Create UI
  your_tasks_label = Label(root, text='THESE ARE YOUR TASKS:', font=('Roboto',10, 'bold'), justify='center')
  your_tasks_label.pack()
  
  
  scrollbar_tasks = tkinter.Scrollbar(root)
  scrollbar_tasks.pack(side=tkinter.RIGHT, fill=tkinter.Y)
  
  listbox_tasks = tkinter.Listbox(root, height=10, width=50, font=('Roboto',10), justify='center') # tkinter.Listbox(where it should go, height=x, width=xx)
  listbox_tasks.pack()
  
  listbox_tasks.config(yscrollcommand=scrollbar_tasks.set)
  scrollbar_tasks.config(command=listbox_tasks.yview)
  
  try:
      #tasks = pickle.load(open('tasks.dat', 'rb'))
      listbox_tasks.delete(0, tkinter.END)
      for task in task_list:
          listbox_tasks.insert(tkinter.END, task)
  except:
      tkinter.messagebox.showwarning(title='Phew', message='You have no tasks')
  
  #BUTTONS
  Add_Button = Button(root, text='Add New', width=42, command=open_add_task)
  Add_Button.pack()
  
  button_delete_task = Button(root, text='Delete task', width=42, command=delete_task)
  button_delete_task.pack()
  
  
  button_save_tasks = Button(root, text='Save tasks', width=42, command=save_tasks)
  button_save_tasks.pack()
  
  #sort_type = StringVar(value='All')
  #OptionMenu(btn_frame, sort_type, 'All', *task_types).grid(column=0, row=0, sticky='nsew')
  
  #sort_imp = StringVar(value='Any')
  #OptionMenu(btn_frame, sort_imp,'Any', *range(0, 10+1)).grid(column=1, row=0, sticky='nsew')
  
  #Button(btn_frame, text='Sort', command=sort_tasks).grid(column=1, row=1, sticky='nsew')
  root.mainloop()
  </code></pre>