Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- whostep = 'X'
- def fun1():
- global whostep
- button_x1_y1["text"] = whostep
- if whostep == 'X':
- whostep = '0'
- elif whostep == '0':
- whostep = 'X'
- check()
- def fun2():
- global whostep
- button_x1_y2["text"] = whostep
- if whostep == '0':
- whostep = 'X'
- elif whostep == 'X':
- whostep = '0'
- def fun3():
- global whostep
- button_x1_y3["text"] = whostep
- if whostep == 'X':
- whostep = '0'
- elif whostep == '0':
- whostep = 'X'
- def fun4():
- global whostep
- button_x2_y1["text"] = whostep
- if whostep == '0':
- whostep = 'X'
- elif whostep == 'X':
- whostep = '0'
- def fun5():
- global whostep
- button_x2_y2["text"] = whostep
- if whostep == 'X':
- whostep = '0'
- elif whostep == '0':
- whostep = 'X'
- def fun6():
- global whostep
- button_x2_y3["text"] = whostep
- if whostep == '0':
- whostep = 'X'
- elif whostep == 'X':
- whostep = '0'
- def fun7():
- global whostep
- button_x3_y1["text"] = whostep
- if whostep == 'X':
- whostep = '0'
- elif whostep == '0':
- whostep = 'X'
- def fun8():
- global whostep
- button_x3_y2["text"] = whostep
- if whostep == '0':
- whostep = 'X'
- elif whostep == 'X':
- whostep = '0'
- def fun9():
- global whostep
- button_x3_y3["text"] = whostep
- if whostep == 'X':
- whostep = '0'
- elif whostep == '0':
- whostep = 'X'
- def check():
- if button_x1_y1 == button_x2_y1 == button_x3_y1:
- label1["text"] = "Победили: X"
- root = Tk()
- root.title("poe-pie")
- root.geometry("350x400")
- title = Label(text="Крестики-нолики", font=('Arial', 14, "bold"))
- title.grid(row=1, column=1, columnspan=3, padx=75)
- button_x1_y1 = Button(text="", width=5, command=fun1)
- button_x1_y1.grid(row=2, column=1, ipadx=6, ipady=6, pady=15)
- button_x1_y2 = Button(text="", width=5, command=fun2)
- button_x1_y2.grid(row=2, column=2, ipadx=6, ipady=6, pady=15)
- button_x1_y3 = Button(text="", width=5, command=fun3)
- button_x1_y3.grid(row=2, column=3, ipadx=6, ipady=6, pady=15)
- button_x2_y1 = Button(text="", width=5, command=fun4)
- button_x2_y1.grid(row=3, column=1, ipadx=6, ipady=6, pady=15)
- button_x2_y2 = Button(text="", width=5, command=fun5)
- button_x2_y2.grid(row=3, column=2, ipadx=6, ipady=6, pady=15)
- button_x2_y3 = Button(text="", width=5, command=fun6)
- button_x2_y3.grid(row=3, column=3, ipadx=6, ipady=6, pady=15)
- button_x3_y1 = Button(text="", width=5, command=fun7)
- button_x3_y1.grid(row=4, column=1, ipadx=6, ipady=6, pady=15)
- button_x3_y2 = Button(text="", width=5, command=fun8)
- button_x3_y2.grid(row=4, column=2, ipadx=6, ipady=6, pady=15)
- button_x3_y3 = Button(text="", width=5, command=fun9)
- button_x3_y3.grid(row=4, column=3, ipadx=6, ipady=6, pady=15)
- label1 = Label(font=('Arial', 14, "bold"))
- label1.grid(row=5, column=1, columnspan=3, padx=75)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement