from guizero import App, PushButton def tl_press(): if top_left.text == "O": top_left.text = "X" else: top_left.text = "O" def tm_press(): if top_mid.text == "O": top_mid.text = "X" else: top_mid.text = "O" def tr_press(): if top_right.text == "O": top_right.text = "X" else: top_right.text = "O" def ml_press(): if mid_left.text == "O": mid_left.text = "X" else: mid_left.text = "O" def mm_press(): if mid_mid.text == "O": mid_mid.text = "X" else: mid_mid.text = "O" def mr_press(): if mid_right.text == "O": mid_right.text = "X" else: mid_right.text = "O" def bl_press(): if bot_left.text == "O": bot_left.text = "X" else: bot_left.text = "O" def bm_press(): if bot_mid.text == "O": bot_mid.text = "X" else: bot_mid.text = "O" def br_press(): if bot_right.text == "O": bot_right.text = "X" else: bot_right.text = "O" app = App(layout="grid", title="TIC-TAC-TOE", width=140, height=132) top_left = PushButton(app, text="...", grid=[0,0], command=tl_press) top_mid = PushButton(app, text="...", grid=[1,0], command=tm_press) top_right = PushButton(app, text="...", grid=[2,0], command=tr_press) mid_left = PushButton(app, text="...", grid=[0,1], command=ml_press) mid_mid = PushButton(app, text="...", grid=[1,1], command=mm_press) mid_right = PushButton(app, text="...", grid=[2,1], command=mr_press) bot_left = PushButton(app, text="...", grid=[0,2], command=bl_press) bot_mid = PushButton(app, text="...", grid=[1,2], command=bm_press) bot_right = PushButton(app, text="...", grid=[2,2], command=br_press) app.display()