Advertisement
k1alo

///

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