Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tictactoe V1
- from guizero import App, Box, PushButton, Text
- app = App(title="TicTacToe V1", width=600, height=500)
- chosen = ""
- def X_button():
- global chosen
- chosen = "X"
- def O_button():
- global chosen
- chosen = "O"
- def square_1():
- location = [0,0]
- mark=marked(location)
- def square_2():
- location = [1,0]
- mark=marked(location)
- def square_3():
- location = [2,0]
- mark=marked(location)
- def square_4():
- location = [0,1]
- mark=marked(location)
- def square_5():
- location = [1,1]
- mark=marked(location)
- def square_6():
- global chosen
- location = [2,1]
- mark=marked(location)
- def square_7():
- location = [0,2]
- mark=marked(location)
- def square_8():
- location = [1,2]
- mark=marked(location)
- def square_9():
- location = [2,2]
- mark=marked(location)
- def marked(location):
- global chosen
- squared = Text(box1, text=chosen, grid=location, color="red", font="Times")
- box1 = Box(app, layout="grid", width=305, height=295, border=4)
- box1.text_size=25
- button1 = PushButton(box1, text="1", width="4", grid=[0,0], command=square_1)
- button2 = PushButton(box1, text="2", width="4", grid=[1,0], command=square_2)
- button3 = PushButton(box1, text="3", width="4", grid=[2,0], command=square_3)
- button4 = PushButton(box1, text="4", width="4", grid=[0,1], command=square_4)
- button5 = PushButton(box1, text="5", width="4", grid=[1,1], command=square_5)
- button6 = PushButton(box1, text="6", width="4", grid=[2,1], command=square_6)
- button7 = PushButton(box1, text="7", width="4", grid=[0,2], command=square_7)
- button8 = PushButton(box1, text="8", width="4", grid=[1,2], command=square_8)
- button9 = PushButton(box1, text="9", width="4", grid=[2,2], command=square_9)
- box2 = Box(app, align="bottom", width="fill", border=True)
- message = Text(box2, text="Choose 'X' or 'O' then choose square ", size=15, align="left")
- button_O = PushButton(box2, align="right", image="O_image.jpg", command=O_button)
- button_X = PushButton(box2, align="right", image="X_image.jpg", command=X_button)
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement