import tkinter
import time
from tkinter import *
from tkinter.messagebox import *
import random
players = []
cplayer = ""
clicks = 0
Xses = None
def count_loop(pole, w, state):
if state:
try:
w.update()
pole.insert(END, "X")
w.after(50, lambda: count_loop(pole, w, state))
except TclError:
pass # Прервать выполнение, если виджет больше не существует
def scount(pole, but, w):
global clicks, state
clicks += 1
if clicks == 1:
state = True
but['text'] = "Stop counting"
count_loop(pole, w, state)
elif clicks == 2:
state = False
but['text'] = "Start counting"
clicks = 0
def start(but, d):
global Xses
but.destroy()
cplayer = players[0]
player = Label(d, text=f"current player: {cplayer}")
player.pack()
c = Button(d, text="Start counting", command=lambda: scount(Xses, c, d))
c.pack()
if Xses is None:
Xses = Text(d)
Xses.pack(fill=BOTH, expand=1)
# Основная программа
st = input("Write the name of player1: ")
st2 = input("Write the name of player2: ")
players.append(st)
players.append(st2)
win = Tk()
win.geometry("500x500")
win.title("AutoCross v1.0b")
tkinter.messagebox.showwarning(title="Current Players", message="Current Players:", detail=f"{players}")
tkinter.messagebox.showerror(title="Debug Failed", message="Debug Failed!", detail="Failed to load module debug.findexploit()")
a = Button(win, text="Start game", command=lambda: start(a, win))
a.pack()
win.mainloop()