title: Updating Listbox containing tuples
body: <p>So I am creating a program that reads in input from wireless switches connected to a raspberry pi. I have them put into a listbox (because i will need to put this on a small screen later) as the switch is pressed in (inserts: 35cb 0) and then as it is pressed out it will delete that previous input and replace it (inserts: 35cb 1). I have 3 switches connected all with different ID's i.e. first four numbers/letters. I'm trying to iterate throught the listbox data and compare it with current list_of_switches (switch pressed/activated) to see if its on the list and if so i just replace it with same ID and different number (from 35cb 0 to 35cb 1)
  Ive got the first switch all working but for any other switch pressed it keeps adding it to the list and not replacing itself if it is released/pressed again. My element 3 and 4 wont change based on switch input only the first two elements will update. Im sure this is an easy fix but i cant seem to figure it out.</p>
  <pre><code>def mainLoop():
  
  
  
          
          switches = switch_collector.items()
          
          type(switches)
          
          list_of_switches = list(switches)
          
          while True:
              
              list_range = len(list_of_switches)
              
              offset = 0
              
              while offset &lt; list_range:
                  
                  pickle_out = open(&quot;Switch_Collector.txt&quot;, &quot;wb&quot;)
                  
                  pickle.dump(list_of_switches, pickle_out)
                  
                  pickle_out.close()
                  list_of_switches = list(list_of_switches)
                  
  
                  if listbox.size() == 0:
                          listbox.insert(END, list_of_switches)
                  for index, tuple in enumerate(list_of_switches):
                          listboxdata = list(listbox.get(index))
                          element_one = tuple[0]
                          element_two = tuple[1]
                  for index, tuple in enumerate(listboxdata):
                         #element_three = tuple[0]
                         #element_four = tuple[1]
                          while index &lt;= listbox.size():
                                  element_three = tuple[0]
                                  element_four = tuple[1]
                                  if element_one == element_three:
                                          listbox.delete(index)
                                          listbox.insert(index, list_of_switches)
                                          break
                                  elif element_one != element_three:
                                          listbox.insert(END, list_of_switches)
                                          break
                  listbox.pack(pady=10)
                  
                      offset += 1
                  
                 
                  if offset &gt;= list_range:
                 
                      break
  
  
  root.after(10, mainLoop)
  </code></pre>
  <p>mainLoop()</p>
  <p>root.mainloop()</p>