SHARE
TWEET

Untitled

a guest Dec 8th, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import tkinter as tk
  2. import random
  3.  
  4. root = tk.Tk()
  5. root.title("Player 1 name")
  6.  
  7.  
  8. def top_level():
  9.     top = tk.Toplevel()
  10.     top.title("Player 2 name")
  11.     player2_label = tk.Label(top, text="Enter second player's name")
  12.     player2_label.pack()
  13.  
  14.     player2_entry = tk.Entry(top, bg="blue")
  15.     player2_entry.pack()
  16.  
  17.     def player2():
  18.         print("Second player's name is :" + player2_entry.get())
  19.         player2_name_window = tk.Toplevel()
  20.         player2_name_window.title("Secret Word!")
  21.         mgw_label = tk.Label(player2_name_window, text="Enter the Secret Word!")
  22.         mgw_label.pack()
  23.         mgw_entry = tk.Entry(player2_name_window, bg="yellow")
  24.         mgw_entry.pack()
  25.  
  26.         def main_window1():
  27.             consonants = ["B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N",
  28.                           "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z"]
  29.             amounts = [500, 550, 600, 650, 700, 750, 800, 850, 2500]
  30.  
  31.             amount_result = random.choice(amounts)
  32.             main = tk.Toplevel()
  33.             main.title("Player 1's turn")
  34.             player1_money = tk.Label(main, text="Player 1" + f"({player1_entry.get()})'s " + "money: " + "P" + str(0))
  35.             player1_money.pack()
  36.             main_label = tk.Label(main, text="Spin the wheel!")
  37.             main_label.pack()
  38.             main_amount_label = tk.Label(main)
  39.             main_amount_label.pack()
  40.             consonants_list = tk.Label(main, state="disabled")
  41.             consonants_list.pack()
  42.             consonants_list_label = tk.Label(main, text=consonants)
  43.             consonants_list_label.pack()
  44.  
  45.             def character_limit(*args):
  46.                 char_len = string_var.get()
  47.                 if len(char_len) > 1:
  48.                     string_var.set(char_len[:1])
  49.  
  50.             string_var = tk.StringVar()
  51.             string_var.trace("w", character_limit)
  52.  
  53.             consonant_entry = tk.Entry(main, state="disabled", bg="orange", textvariable=string_var)
  54.             consonant_entry.pack()
  55.  
  56.             def spin():
  57.                 main_amount_label.config(text=amount_result)
  58.                 # player1_money.config(text="Player 1" + f"({player1_entry.get()})'s " + "money: " + "P" + str(amount_result))
  59.                 consonant_entry.config(state="normal")
  60.                 consonants_list.config(text="Enter a consonant!", state="normal")
  61.                 player1_consonant = str(consonant_entry.get()).upper()
  62.                 # print(player1_consonant)
  63.  
  64.  
  65.  
  66.                 def submit_consonant():
  67.                     if player1_consonant in consonants:
  68.                         # print("WORKING")
  69.                         consonants.remove(player1_consonant)
  70.                         consonants_list_label.config(text=consonants)
  71.                         main_btn.config(state="disabled")
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.             main_btn = tk.Button(main, text="SPIN!", command=spin)
  80.             main_btn.pack()
  81.  
  82.  
  83.             # print("The secret word is:" + str(len(mgw_entry.get()) * "-"))
  84.  
  85.         mgw_btn = tk.Button(player2_name_window, text="Submit", command=main_window1)
  86.         mgw_btn.pack()
  87.  
  88.     top_btn = tk.Button(top, text="Submit", command=player2)
  89.     top_btn.pack()
  90.  
  91.  
  92. def functions():
  93.     top_level()
  94.     print("First player's name is: " + player1_entry.get())
  95.  
  96.  
  97. player1_label = tk.Label(root, text="Enter first player's name")
  98. player1_label.pack()
  99. player1_entry = tk.Entry(root, bg="green")
  100. player1_entry.pack()
  101.  
  102.  
  103. submit = tk.Button(root, text="Submit", command=functions)
  104. submit.pack()
  105.  
  106. root.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top