Advertisement
tokyoedtech

NHL Teams.py

Jan 5th, 2017
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.72 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import messagebox
  3. import os
  4. import sys
  5.  
  6. #Create a window named root
  7. root = Tk()
  8. root.title("NHL Scoreboard!")
  9.  
  10. Team_Name="Unassigned"
  11.  
  12. #tn_name fuctions assign the team name when the associated team button is clicked
  13. def tn_Anaheim_Ducks():
  14.     global Team_Name
  15.     Team_Name="Ducks"
  16.     lbl_Team_Name.config(text="Anaheim Ducks")
  17.    
  18. def tn_Boston_Bruins():
  19.     global Team_Name
  20.     Team_Name="Bruins"
  21.     lbl_Team_Name.config(text="Boston Bruins")
  22.    
  23. def function_start():
  24.     lbl_Team_Name.config(text="Start")
  25.  
  26. def main():
  27.     global root
  28.     global Team_Name
  29.     if Team_Name == "Unassigned":
  30.         messagebox.showinfo("Title", "a Tk MessageBox")
  31.     else:    
  32.         main = Tk()
  33.         main.title("Main!")
  34.         root.destroy()
  35.         lbl_Team_Def = Label(main, text="Assigned Team: ")
  36.         lbl_Team_Def.grid(row=1,column=0)
  37.  
  38.         lbl_Team_Name = Label(main, text=Team_Name,anchor='w')
  39.         lbl_Team_Name.grid(row=1,column=1)
  40.  
  41. #Declare the team pictures
  42.  
  43. #Declare the buttons with associated team logo/name
  44. btn_Anaheim_Ducks = Button(root,text="Anaheim Ducks",compound="top",command=tn_Anaheim_Ducks)
  45. btn_Boston_Bruins = Button(root,text="Boston Bruins",compound="top",command=tn_Boston_Bruins)
  46. btn_Start = Button(root,text="Start", compound="top",command=main,width=12,height=3)
  47.  
  48. #Organize the buttons in a 5x6 grid
  49. btn_Anaheim_Ducks.grid(row=1,column=1)
  50. btn_Boston_Bruins.grid(row=1,column=2)
  51.  
  52. lbl_Team_Def = Label(root, text="Assigned Team: ")
  53. lbl_Team_Def.grid(row=7,column=1)
  54.  
  55. lbl_Team_Name = Label(root, text=Team_Name,anchor='w')
  56. lbl_Team_Name.grid(row=7,column=2)
  57.  
  58. btn_Start.grid(row=7,column=3)
  59.  
  60. #Run the main windows
  61. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement