SHARE
TWEET

Untitled

a guest Dec 8th, 2019 83 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 check_consonant():
  46.                 consonant_answer = str(consonant_entry.get()).upper()
  47.                 if consonant_answer in consonants:
  48.                     consonants.remove(consonant_answer)
  49.                     consonants_list_label.config(text=consonants)
  50.                     player1_money.config(text="Player 1" + f"({player1_entry.get()})'s " + "money: " + "P" + str(amount_result))
  51.  
  52.             def character_limit(*args):
  53.                 char_len = string_var.get()
  54.                 string_var.set(char_len[:1])
  55.                 global submit_consonant
  56.                 if len(char_len) == 1:
  57.                     submit_consonant = tk.Button(main, text="Submit", command=check_consonant)
  58.                     submit_consonant.pack()
  59.                 if len(char_len) == 0:
  60.                     submit_consonant.pack_forget()
  61.  
  62.             string_var = tk.StringVar()
  63.             string_var.trace("w", character_limit)
  64.  
  65.             consonant_entry = tk.Entry(main, state="disabled", bg="orange", textvariable=string_var)
  66.             consonant_entry.pack()
  67.  
  68.             def spin():
  69.                 main_amount_label.config(text=amount_result)
  70.                 # player1_money.config(text="Player 1" + f"({player1_entry.get()})'s " + "money: " + "P" + str(amount_result))
  71.                 consonant_entry.config(state="normal")
  72.                 consonants_list.config(text="Enter a consonant!", state="normal")
  73.                 player1_consonant = str(consonant_entry.get()).upper()
  74.                 # print(player1_consonant)
  75.  
  76.                 def submit_consonant():
  77.                     if player1_consonant in consonants:
  78.                         # print("WORKING")
  79.                         consonants.remove(player1_consonant)
  80.                         consonants_list_label.config(text=consonants)
  81.                         main_btn.config(state="disabled")
  82.  
  83.             main_btn = tk.Button(main, text="SPIN!", command=spin)
  84.             main_btn.pack()
  85.             # print("The secret word is:" + str(len(mgw_entry.get()) * "-"))
  86.  
  87.         mgw_btn = tk.Button(player2_name_window, text="Submit", command=main_window1)
  88.         mgw_btn.pack()
  89.  
  90.     top_btn = tk.Button(top, text="Submit", command=player2)
  91.     top_btn.pack()
  92.  
  93.  
  94. def functions():
  95.     top_level()
  96.     print("First player's name is: " + player1_entry.get())
  97.  
  98.  
  99. player1_label = tk.Label(root, text="Enter first player's name")
  100. player1_label.pack()
  101. player1_entry = tk.Entry(root, bg="green")
  102. player1_entry.pack()
  103.  
  104.  
  105. submit = tk.Button(root, text="Submit", command=functions)
  106. submit.pack()
  107.  
  108. 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
 
Top