Advertisement
k1alo

///1

Dec 14th, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.07 KB | None | 0 0
  1. from tkinter import *
  2.  
  3. current_player = "X"
  4.  
  5.  
  6. def fun1():
  7.     global current_player
  8.     button_x1_y1["text"] = current_player
  9.     if current_player == 'X':
  10.         current_player = '0'
  11.     elif current_player == '0':
  12.         current_player = 'X'
  13.     check()
  14.  
  15.  
  16. def fun2():
  17.     global current_player
  18.     button_x1_y2["text"] = current_player
  19.     if current_player == '0':
  20.         current_player = 'X'
  21.     elif current_player == 'X':
  22.         current_player = '0'
  23.     check()
  24.  
  25.  
  26. def fun3():
  27.     global current_player
  28.     button_x1_y3["text"] = current_player
  29.     if current_player == 'X':
  30.         current_player = '0'
  31.     elif current_player == '0':
  32.         current_player = 'X'
  33.     check()
  34.  
  35.  
  36. def fun4():
  37.     global current_player
  38.     button_x2_y1["text"] = current_player
  39.     if current_player == '0':
  40.         current_player = 'X'
  41.     elif current_player == 'X':
  42.         current_player = '0'
  43.     check()
  44.  
  45. def fun5():
  46.     global current_player
  47.     button_x2_y2["text"] = current_player
  48.     if current_player == 'X':
  49.         current_player = '0'
  50.     elif current_player == '0':
  51.         current_player = 'X'
  52.     check()
  53.  
  54. def fun6():
  55.     global current_player
  56.     button_x2_y3["text"] = current_player
  57.     if current_player == '0':
  58.         current_player = 'X'
  59.     elif current_player == 'X':
  60.         current_player = '0'
  61.     check()
  62.  
  63.  
  64. def fun7():
  65.     global current_player
  66.     button_x3_y1["text"] = current_player
  67.     if current_player == 'X':
  68.         current_player = '0'
  69.     elif current_player == '0':
  70.         current_player = 'X'
  71.     check()
  72.  
  73.  
  74. def fun8():
  75.     global current_player
  76.     button_x3_y2["text"] = current_player
  77.     if current_player == '0':
  78.         current_player = 'X'
  79.     elif current_player == 'X':
  80.         current_player = '0'
  81.     check()
  82.  
  83.  
  84. def fun9():
  85.     global current_player
  86.     button_x3_y3["text"] = current_player
  87.     if current_player == 'X':
  88.         current_player = '0'
  89.     elif current_player == '0':
  90.         current_player = 'X'
  91.     check()
  92.  
  93.  
  94. def check():
  95.     if button_x1_y1 == button_x1_y2 == button_x1_y3 != " ":
  96.         return True
  97.     elif button_x1_y1 == button_x2_y2 == button_x3_y3 != " ":
  98.         return True
  99.     elif button_x1_y1 == button_x2_y1 == button_x3_y1 != " ":
  100.         return True
  101.     elif button_x1_y2 == button_x2_y2 == button_x3_y2 != " ":
  102.         return True
  103.     elif button_x1_y3 == button_x2_y3 == button_x3_y3 != " ":
  104.         return True
  105.     elif button_x1_y3 == button_x2_y2 == button_x3_y1 != " ":
  106.         return True
  107.     elif button_x2_y1 == button_x2_y2 == button_x2_y3 != " ":
  108.         return True
  109.     elif button_x3_y1 == button_x3_y2 == button_x3_y3 != " ":
  110.         return True
  111.  
  112. def click():
  113.    
  114.  
  115.  
  116.  
  117.  
  118. root = Tk()
  119. root.title("poe-pie")
  120. root.geometry("350x400")
  121.  
  122. title = Label(text="Крестики-нолики", font=('Arial', 14, "bold"))
  123. title.grid(row=1, column=1, columnspan=3, padx=75)
  124.  
  125. button_x1_y1 = Button(text="", width=5, command=fun1)
  126. button_x1_y1.grid(row=2, column=1, ipadx=6, ipady=6, pady=15)
  127.  
  128. button_x1_y2 = Button(text="", width=5, command=fun2)
  129. button_x1_y2.grid(row=2, column=2, ipadx=6, ipady=6, pady=15)
  130.  
  131. button_x1_y3 = Button(text="", width=5, command=fun3)
  132. button_x1_y3.grid(row=2, column=3, ipadx=6, ipady=6, pady=15)
  133.  
  134. button_x2_y1 = Button(text="", width=5, command=fun4)
  135. button_x2_y1.grid(row=3, column=1, ipadx=6, ipady=6, pady=15)
  136.  
  137. button_x2_y2 = Button(text="", width=5, command=fun5)
  138. button_x2_y2.grid(row=3, column=2, ipadx=6, ipady=6, pady=15)
  139.  
  140. button_x2_y3 = Button(text="", width=5, command=fun6)
  141. button_x2_y3.grid(row=3, column=3, ipadx=6, ipady=6, pady=15)
  142.  
  143. button_x3_y1 = Button(text="", width=5, command=fun7)
  144. button_x3_y1.grid(row=4, column=1, ipadx=6, ipady=6, pady=15)
  145.  
  146. button_x3_y2 = Button(text="", width=5, command=fun8)
  147. button_x3_y2.grid(row=4, column=2, ipadx=6, ipady=6, pady=15)
  148.  
  149. button_x3_y3 = Button(text="", width=5, command=fun9)
  150. button_x3_y3.grid(row=4, column=3, ipadx=6, ipady=6, pady=15)
  151.  
  152. label1 = Label(font=('Arial', 14, "bold"))
  153. label1.grid(row=5, column=1, columnspan=3, padx=75)
  154.  
  155. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement