title: Python Tkinter: Delete all contents from ListBox
body: <p>Hey guys pretty sure this is a simple fix, but I can't find anything. Basically I'm filling a listbox, and I need it to update (pseudo update) whenever a user clicks a label in the listbox.</p>
  
  <p>My only problem is deleting all contents from the listbox. Below I have the function I implemented. Thank you in advance!</p>
  
  <pre><code>class SocketThreadedTask(threading.Thread):
  def _init_(self, socket, callback):
      threading.Thread._init_(self)
      self.socket = socket
      self.callback = callback
      self.allChannels = None
      self.privateChannels = {}
      self.publicChannels = {}
      self.channelMessages = {}
  
  def run(self):
      channels = None
      messages = None
      while True:
          try:
              message = self.socket.receive()
              if message[0] == "channels":
                  self.allChannels = message[1]
                  for key, value in self.allChannels.items():
                      if key[0] == '+':
                          oldKey = key
                          newKey = key[1:]
                          self.allChannels[newKey] = value
                          del self.allChannels[oldKey]
                          self.publicChannels[key] = value
                      elif key[0] == '-':
                          key = key[1:]
                          self.privateChannels[key] = value
                  message = message[0]
                  self.callback(None, self.allChannels, None)
              elif message[0] == "messages":
                  self.channelMessages = messages = message[1]
                  message = message[0]
                  self.callback(message, None, messages)
              else:
                  message = message[0]
                  self.callback(message, None, None)
              if message == '/quit':
                  self.callback('&gt; You have been disconnected from the chat room.')
                  self.socket.disconnect()
                  break
          except OSError:
              break
  
  class ChatWindow(tk.Frame):
  def _init_(self, parent):
      tk.Frame._init_(self, parent)
  
      self.initUI(parent)
  
  def initUI(self, parent):
      self.messageScrollbar = tk.Scrollbar(parent, orient=tk.VERTICAL)
      self.messageScrollbar.grid(row=0, column=3, sticky="ns")
  
      self.messageTextArea = tk.Text(parent, bg="white", state=tk.DISABLED, yscrollcommand=self.messageScrollbar.set, wrap=tk.WORD)
      self.messageTextArea.grid(row=0, column=0, columnspan=2, sticky="nsew")
  
      # list of users
      self.usersListBox = tk.Listbox(parent, bg="white")
      self.usersListBox.grid(row=0, column=4, padx=5, sticky="nsew")
  
      self.entryField = entry.BaseEntry(parent, placeholder="Enter message.", width=80)
      self.entryField.grid(row=1, column=0, padx=5, pady=10, sticky="we")
  
      self.send_message_button = tk.Button(parent, text="Send", width=10, bg="#CACACA", activebackground="#CACACA")
      self.send_message_button.grid(row=1, column=1, padx=5, sticky="we")
  
  def update_window(self, message, channels, messages):
      if (message is None) and (messages is None):
          self.refresh_users(channels)
      elif (channels is None) and (message is None):
          self.refresh_messages(messages)
      elif (channels is None) and (messages is None):
          self.update_chat_window(message)
  
  def refresh_users(self, channels = {}):
       self.usersListBox.delete(0, END)
       self.usersListBox.insert(0, "Channels")
       if bool(channels) is True:
            count = 1
            for key, value in channels.items():
                 label = Label(self.userListBox, text=key)
                 label.pack()
                 label.bind(None, self.switch(label.cget("text")))
                 self.usersListBox.insert(count, label)
                 count += 1
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/DnJjG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DnJjG.jpg" alt="This is before I message, on the first update."></a></p>
  
  <p>I will attach 2 images<a href="https://i.stack.imgur.com/3jAg1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3jAg1.jpg" alt="When anyone on the channel speaks, it&#39;s supposed to update the listbox."></a></p>