title: Creating Toplevel after receiveing some input on socket
body: <p>I'm using this forum for some time, but first time asking question.
  I have problem with one tkinter application. It's simple chat server - client program, where chat is something like Skype. I have a friend list, and when I select friend from list, click chat, new window (toplevel) opens. Then I can send messages to friend.
  Problem is on the other side. It's working fine if chat window is opened on the other side, but if it's not, I'm trying to create in by calling function that creates new toplevel. And here program freezes (on the side of friend).</p>
  
  <pre><code>def bChatPress(self, event=None):
          def closeChatClient():
              chatClient.destroy()
              del self.chatClients[friend]
  
          if self.friend=='':
              index = self.lbFriends.curselection()
              if index:
                  friend = self.lbFriends.get(index)
                  if friend not in self.chatClients:
                      chatClient=ChatClient(self, self.user, friend)
                      chatClient.protocol("WM_DELETE_WINDOW", closeChatClient)
                      self.chatClients[friend] = chatClient
          else:
              chatClient=ChatClient(self, self.user, self.friend)
              chatClient.protocol("WM_DELETE_WINDOW", closeChatClient)
              self.chatClients[self.friend] = chatClient
              self.friend=''
  
  def receiveMessage(self):
          def loop():
              print('threadstart')
              while self.loged:
                  try:
                      message = self.socket.recv(1024).decode('ascii')
                      print(message)
                      if '{LOGIN}' in message:
                          threading.Thread(target=self.login).start()
                      elif '{LOGOUT}' in message:
                          pass
                      elif '{CONNECT}' in message:
                          self.connect(message.replace('{CONNECT}',''))
                      elif '{DISCONNECT}' in message:
                          self.disconnect()
                      elif '{ADD FRIEND}' in message:
                          self.populateFriendsList(message.replace('{ADD FRIEND}',''))
                      elif '{DELETE FRIEND}' in message:
                          self.populateFriendsList(message.replace('{DELETE FRIEND}',''))
                      elif '{USER CONNECT}' in message:
                          self.checkOnline()
                      elif '{USER DISCONNECT}' in message:
                          self.checkOnline()
                      elif '{CHECK ONLINE}' in message:
                          self.populateFriendsList(message.replace('{CHECK ONLINE}',''))
                      elif '{MESSAGE}' in message:
                          self.processMessage(message.replace('{MESSAGE}',''))
                  except Exception as error:
                      pass
  
          threading.Thread(target=loop).start()
  </code></pre>
  
  <p>This is function for creating chat window. It's working fine when I create window by clicking the button, but it's not working when I call this function from receiveMessage function (this is loop for listening socket)</p>
  
  <p>Did anybody had this problem before?
  Thanks in advance.</p>