title: Python menu update
body: <p>I am developing a GUI in Python in which a team is selected from a menu. When a team is selected, a command should be executed in which a value PD is calculated based on values in the slider. I'm having two problems. 1) the value is not updated from the slider values. I am using the .get() function but it doesn't seem to be working. 2) the sliders are getting stacked on each other when a new team is selected. How do I clear the first set so a new set is created for each team? Here is my code: any thoughts?</p>
  
  <pre><code>from Tkinter import *
  import tkMessageBox
  import Tkinter
  
  
  root = Tk()
  root.title("NBA Point Differentials Predictor")
  root.geometry("300x680")
  
  mb =  Menubutton (root, text = "Select Team", relief = RAISED, pady = 8)
  mb.grid()
  mb.menu  =  Menu ( mb, tearoff = 0)
  mb["menu"]  =  mb.menu
  
  
  def sel():
      selection = "Point differential = " + str(PD)
      label.config(text = selection)
  
  FGP = DoubleVar();TPP = DoubleVar(); FTP = DoubleVar(); ORB = DoubleVar(); TRB = DoubleVar();
  AST = DoubleVar(); STL = DoubleVar(); BLK = DoubleVar(); TOV = DoubleVar(); PF = DoubleVar(); 
  
  def ATL():
  
      index = 1
  
      if index == 1: 
  
          FGP_mean = 0.47; TPP_mean = 0.4; FTP_mean = 0.78; ORB_mean = 8.5;
          TRB_mean = 40.6; AST_mean = 25.8; STL_mean = 9.06; BLK_mean = 4.63;
          TOV_mean = 13.5; PF_mean = 17.7;
  
          slider_order = [5, 1, 9, 7, 6, 3, 4, 2, 8, 10]
  
          for x in slider_order:
  
              if x == 1:
                  scale1 = Scale(root, from_=0, to=1, resolution = 0.01, variable = FGP, orient = HORIZONTAL, label = "Field goal percentage")
                  scale1.set(FGP_mean)
                  scale1.grid()
              elif x == 2:
                  scale2 = Scale(root, from_=0, to=1, resolution = 0.01, variable = TPP, orient = HORIZONTAL, label = "3-point field goal percentage")
                  scale2.set(TPP_mean)
                  scale2.grid()
              elif x == 3:
                  scale3 = Scale(root, from_=0, to=1, resolution = 0.01, variable = FTP, orient = HORIZONTAL, label = "Free throw percentage")
                  scale3.set(FTP_mean)
                  scale3.grid()
              elif x == 4:
                  scale4 = Scale(root, from_=0, to=50, variable = ORB, orient = HORIZONTAL, label = "Offensive rebounds")
                  scale4.set(ORB_mean)
                  scale4.grid()
              elif x == 5:
                  scale5 = Scale(root, from_=0, to=100, variable = TRB, orient = HORIZONTAL, label = "Total rebounds")
                  scale5.set(TRB_mean)
                  scale5.grid()
              elif x == 6:
                  scale6 = Scale(root, from_=0, to=50, variable = AST, orient = HORIZONTAL, label = "Assists")
                  scale6.set(AST_mean)
                  scale6.grid()
              elif x == 7:
                  scale7 = Scale(root, from_=0, to=30, variable = STL, orient = HORIZONTAL, label = "Steals")
                  scale7.set(STL_mean)
                  scale7.grid()
              elif x == 8:
                  scale8 = Scale(root, from_=0, to=30, variable = BLK, orient = HORIZONTAL, label = "Blocks")
                  scale8.set(BLK_mean)
                  scale8.grid()
              elif x == 9:
                  scale9 = Scale(root, from_=0, to=50, variable = TOV, orient = HORIZONTAL, label = "Turnovers")
                  scale9.set(TOV_mean)
                  scale9.grid()
              else:  
                  scale10 = Scale(root, from_=0, to=50, variable = PF, orient = HORIZONTAL, label = "Personal fouls")
                  scale10.set(PF_mean)
                  scale10.grid()
  
          global PD
  
          PD = -123.9319 + 114.58945*FGP.get() + 12.48279*TPP.get() + 14.62438*FTP.get() - 0.41907*ORB.get() + 1.36049*TRB.get() + 0.46082*AST.get() + 1.17966*STL.get() + 0.18258*BLK.get() -1.16002*TOV.get() + 0.02497*PF.get()
  
  
  def BOS():
  
      index = 2
  
      if index == 2:
  
          FGP_mean = 0.44; TPP_mean = 0.32; FTP_mean = 0.76; ORB_mean = 11.14;
          TRB_mean = 43.94; AST_mean = 24.22; STL_mean = 8.038; BLK_mean = 3.59;
          TOV_mean = 13.29; PF_mean = 21.24;
  
          slider_order = [1, 5, 9, 7, 4, 2, 10, 6, 3, 8]
  
          for x in slider_order:
  
              if x == 1:
                  scale1 = Scale(root, from_=0, to=1, resolution = 0.01, variable = FGP, orient = HORIZONTAL, label = "Field goal percentage")
                  scale1.set(FGP_mean)
                  scale1.grid()
              elif x == 2:
                  scale2 = Scale(root, from_=0, to=1, resolution = 0.01, variable = TPP, orient = HORIZONTAL, label = "3-point field goal percentage")
                  scale2.set(TPP_mean)
                  scale2.grid()
              elif x == 3:
                  scale3 = Scale(root, from_=0, to=1, resolution = 0.01, variable = FTP, orient = HORIZONTAL, label = "Free throw percentage")
                  scale3.set(FTP_mean)
                  scale3.grid()
              elif x == 4:
                  scale4 = Scale(root, from_=0, to=50, variable = ORB, orient = HORIZONTAL, label = "Offensive rebounds")
                  scale4.set(ORB_mean)
                  scale4.grid()
              elif x == 5:
                  scale5 = Scale(root, from_=0, to=100, variable = TRB, orient = HORIZONTAL, label = "Total rebounds")
                  scale5.set(TRB_mean)
                  scale5.grid()
              elif x == 6:
                  scale6 = Scale(root, from_=0, to=50, variable = AST, orient = HORIZONTAL, label = "Assists")
                  scale6.set(AST_mean)
                  scale6.grid()
              elif x == 7:
                  scale7 = Scale(root, from_=0, to=30, variable = STL, orient = HORIZONTAL, label = "Steals")
                  scale7.set(STL_mean)
                  scale7.grid()
              elif x == 8:
                  scale8 = Scale(root, from_=0, to=30, variable = BLK, orient = HORIZONTAL, label = "Blocks")
                  scale8.set(BLK_mean)
                  scale8.grid()
              elif x == 9:
                  scale9 = Scale(root, from_=0, to=50, variable = TOV, orient = HORIZONTAL, label = "Turnovers")
                  scale9.set(TOV_mean)
                  scale9.grid()
              else:  
                  scale10 = Scale(root, from_=0, to=50, variable = PF, orient = HORIZONTAL, label = "Personal fouls")
                  scale10.set(PF_mean)
                  scale10.grid()
  
          global PD
  
          PD = -95.6789 + 135.5622*FGP.get() + 13.2779*TPP.get() + 7.1998*FTP.get() - 0.5649*ORB.get() + 1.0487*TRB.get() - 0.2041*AST.get() + 1.4290*STL.get() - 0.2492*BLK.get() - 1.2071*TOV.get() - 0.1919*PF.get()
  
  
  
  def BRK():
  
      FGP_mean = 0.45; TPP_mean = 0.33; FTP_mean = 0.75; ORB_mean = 10.24;
      TRB_mean = 42.28; AST_mean = 20.94; STL_mean = 7.0; BLK_mean = 4.18;
      TOV_mean = 13.45; PF_mean = 19.0;
  
      slider_order = [5, 1, 7, 9, 2, 4, 3, 6, 10, 8]
  
      for x in slider_order:
  
          if x == 1:
              scale1 = Scale(root, from_=0, to=1, resolution = 0.01, variable = FGP, orient = HORIZONTAL, label = "Field goal percentage")
              scale1.set(FGP_mean)
              scale1.grid()
          elif x == 2:
              scale2 = Scale(root, from_=0, to=1, resolution = 0.01, variable = TPP, orient = HORIZONTAL, label = "3-point field goal percentage")
              scale2.set(TPP_mean)
              scale2.grid()
          elif x == 3:
              scale3 = Scale(root, from_=0, to=1, resolution = 0.01, variable = FTP, orient = HORIZONTAL, label = "Free throw percentage")
              scale3.set(FTP_mean)
              scale3.grid()
          elif x == 4:
              scale4 = Scale(root, from_=0, to=50, variable = ORB, orient = HORIZONTAL, label = "Offensive rebounds")
              scale4.set(ORB_mean)
              scale4.grid()
          elif x == 5:
              scale5 = Scale(root, from_=0, to=100, variable = TRB, orient = HORIZONTAL, label = "Total rebounds")
              scale5.set(TRB_mean)
              scale5.grid()
          elif x == 6:
              scale6 = Scale(root, from_=0, to=50, variable = AST, orient = HORIZONTAL, label = "Assists")
              scale6.set(AST_mean)
              scale6.grid()
          elif x == 7:
              scale7 = Scale(root, from_=0, to=30, variable = STL, orient = HORIZONTAL, label = "Steals")
              scale7.set(STL_mean)
              scale7.grid()
          elif x == 8:
              scale8 = Scale(root, from_=0, to=30, variable = BLK, orient = HORIZONTAL, label = "Blocks")
              scale8.set(BLK_mean)
              scale8.grid()
          elif x == 9:
              scale9 = Scale(root, from_=0, to=50, variable = TOV, orient = HORIZONTAL, label = "Turnovers")
              scale9.set(TOV_mean)
              scale9.grid()
          else:  
              scale10 = Scale(root, from_=0, to=50, variable = PF, orient = HORIZONTAL, label = "Personal fouls")
              scale10.set(PF_mean)
              scale10.grid()
  
      global PD
  
      PD = -143.6673 + 139.9460*FGP.get() + 29.1870*TPP.get() + 20.6729*FTP.get() - 0.8086*ORB.get() + 1.4133*TRB.get() - 0.2628*AST.get() + 1.8273*STL.get() + 0.3091*BLK.get() - 0.8778*TOV.get() + 0.1976*PF.get()
  
  mb.menu.add_command(label="Atlanta Hawks", command=ATL)
  mb.menu.add_command(label="Boston Celtics", command=BOS)
  mb.menu.add_command(label="Brooklyn Nets", command=BRK)
  
  
  
  app = Frame(root)
  app.grid
  
  button = Button(root, text = "Get Point Differential", command=sel)
  button.grid()
  
  label = Label(root)
  label.grid()
  
  root.config(menu=mb)
  root.mainloop()
  </code></pre>