title: Find the path taken by the user in a drop down menu
body: <p>I am using menu widgets in tkinter to create a drop down menu, I need to have some code, so that when one of the commands are clicked, the route taken by the user to get to that command is found. This is because the command needed will be dependent on which route the user has taken to get to that command. How can I find the path taken by the user? Here is my code</p>
  
  <pre><code>team1 = 'Lakers'
  team2 = 'Celtics'
  
  def makeShot():
      print ("Shot was made by")
  
  # Setting up the window and the title etc.     
  root = Tk()
  root.title("Basketball Code")
  root.geometry("850x700")
  
  # Lists for the 2 teams.
  team1Players = ("Zach Auguste", "Tarik Black", "Anthony Brown", "Jose Calderon", "Luol Deng")
  team2Players = ("Ben Bentil", "Avery Bradley", "Jaylen Brown", "Jae Crowder", "Gerald Green")
  
  # Create a popup menu for selecting a team. 
  teamMenu = Menu(root)
  
  Team2Menu = Menu(root)
  Team1Menu = Menu(root)
  
  # Create the 2 options for picking the teams.
  teamMenu.add_cascade(label=team1, menu = Team1Menu)
  teamMenu.add_cascade(label=team2, menu = Team2Menu)
  
  # Adding the player names to the drop down list
  team1Menu = Menu(root)
  for i in range(len(team1Players)):
      Team1Menu.add_cascade(label=team1Players[i], menu=team1Menu)
  
  # Adding the player names to the drop down list
  team2Menu = Menu(root)
  for i in range(len(team2Players)):
      Team2Menu.add_cascade(label=team2Players[i], menu=team2Menu)
  
  #Adding the options to the players name list.
  shotTypeMenu = Menu(root)
  team1Menu.add_cascade(label= "3pt", menu=shotTypeMenu)
  team1Menu.add_cascade(label= "2pt", menu=shotTypeMenu)
  team2Menu.add_cascade(label= "3pt", menu=shotTypeMenu)
  team2Menu.add_cascade(label= "2pt", menu=shotTypeMenu)
  
  
  #Adding the options to the players name list.
  shotSuccessMenu = Menu(root)
  shotTypeMenu.add_command(label= "Make", command = makeShot)
  shotTypeMenu.add_command(label= "Miss", command = None)
  
  def popup(event):
      teamMenu.post(event.x_root, event.y_root)
      print(event.x,",",event.y)
  
  #Attach popup to frame
  root.bind("&lt;Button-3&gt;", popup)
  
  root.mainloop()
  </code></pre>