title: Python 2.7: Adding new items to Tkinter listbox without adding existing values
body: <p>I am writing a simple bulk file utility. I have two listboxes in the GUI. Listbox1 contains a list of files that exist in whichever directory the user selects. The user can then add selected items in listbox1, to listbox2. Currently this allows duplicate items to be added. I would like to figure out how to check if selected items already exist in listbox2, and only add items that aren't already present.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>from Tkinter import * 
  import Tkinter, Tkconstants, tkFileDialog, tkMessageBox
  import os, sys
  
  
  
  class FileZap():
      def __init__(self, root):
  
          def getDir():
              dir = tkFileDialog.askdirectory(initialdir="C:/")
              self.user1.delete(0,END)
              self.user1.insert(0,dir)
              files = (file for file in os.listdir(dir)
                  if os.path.isfile(os.path.join(dir, file)))
              for file in files:
                  self.listbox1.insert(0,file)
  
          def selectAdd():
              selection1 = self.listbox1.curselection()
              for i in selection1:
                  selectedFiles = self.listbox1.get(i)
                  self.listbox2.insert(0, selectedFiles)
  
          root.title("Test_App 1.0")
          root.geometry("860x450")    
          self.listbox1 = Listbox(root, width=50, selectmode="multiple")
          self.listbox1.grid(row=2, column=2)
          self.scrollbar = Scrollbar(orient=VERTICAL, command=self.listbox1.yview)
          self.listbox1.config(yscrollcommand=self.scrollbar.set)
          self.scrollbar.grid(row=2, column=3, sticky="ns")
          self.listbox2 = Listbox(root, width=50)
          self.listbox2.grid(row=2, column=4)
          self.label1 = Label(root, text="Select a folder: ")
          self.label1.grid(row=1, column=1)
          self.user1 = Entry(root, width="50")
          self.user1.grid(row=1, column=2)
          self.browse = Button(root, text="Browse", command=getDir)
          self.browse.grid(row=1, column=3)
          self.button2 = Button(root, text="Add to Selection", command=selectAdd)
          self.button2.grid(row=3, column=3)
  
          self.quit = Button(root, text="Exit", command=root.quit)
          self.quit.grid(row=8, column=4)
  
  
  root = Tkinter.Tk()
  file_zap = FileZap(root)
  root.mainloop()
  </code></pre>
  
  <p>In the above code the function selectAdd() performs the item manipulation. I was hoping to do this by adding another for loop within the function that returns the values in listbox2, and adding items if not in listbox2. However I can only seem to return selected values using .get, I can't figure out how to select all values. Also I'm not sure that this is even the best way to do this. Any help would be much appreciated!</p>