Anonymous  
									
						
		
						
						
		 
		
						
						 Wie kann ich dieses Spiel für Sekunden stoppen und dort beginnen, wo es gestoppt wurde? 
													
							
						
									
						Post 
					 
								by Anonymous  30 Oct 2025, 14:13 
			
			
			
			
			Ich habe ein Spiel mit Python Tkinter geschrieben, weiß aber nicht, dass es definitiv aufhören soll? />
Code: Select all 
from tkinter import *
from tkinter import messagebox
import random
win = Tk()
win.title('Color game')
win.geometry('500x500')
win.config(bg = "#C1AB8C")
win.resizable(0,0)
#================================function=====================================
colors = ['Yellow' , 'Blue' , 'Green' , 'Black' , 'Red' , 'Orange' , 'White' , 'Purple' , 'Brown']
score = 0
timeleft = 45
def startgame(event):
if timeleft == 45 :
countdown()
nextcolor()
def nextcolor():
global score
global timeleft
if timeleft > 0 :
ent.focus_set()
if ent.get().strip():
if ent.get().lower() == colors[1].lower():
lbl_feedback.config(text = 'CORRECT!' , fg = '#075B21')
score += 1
else:
lbl_feedback.config(text = 'WRONG!' , fg = '#AE1717')
else:
lbl_feedback.config(text= '')
ent.delete(0 , END)
random.shuffle(colors)
lbl_color.config(fg = str(colors[1]) , text = str(colors[0]))
lbl_score.config(text = 'Score :' + str(score) , font = ('comic sans ms' , 16 , 'bold') )
def countdown():
global timeleft
if timeleft > 0 :
timeleft -= 1
lbl_time.config(text='Time :' + str(timeleft) , font = ('comic sans ms' , 16 , 'bold'))
lbl_time.after(1000 , countdown)
if timeleft == 0 :
messagebox.showinfo('End' , 'Times up!')
if timeleft  0 :
lbl_hurry_up.config(text ='Hurry up ,you are\n runing out of time!!!\U0001f630' )
def escape(event):
global timeleft
result = messagebox.askquestion('Quit' , 'Are you sure to quit?')
if result == 'yes':
win.destroy()
#================================label========================================
lbl_question = Label(win , text = 'Enter the color of each word.' , font = ('comic sans ms' , 19 , 'bold'))
lbl_question.place(x = 60 , y = 20)
lbl_time = Label(win , text = 'Time :' , font = ('comic sans ms' , 16 , 'bold'))
lbl_time.place(x = 130, y = 70)
lbl_hurry_up = Label(win , text = '' , font = 'arial 13 bold' , bg = "#C1AB8C" , fg = "#B80000")
lbl_hurry_up.place(x = 290 , y = 70)
lbl_score = Label(win , text = 'Score :' , font = ('comic sans ms' , 16 , 'bold'))
lbl_score.place(x = 130 , y = 115)
lbl_color = Label(win , text = '' , font = 'arial 33 bold' , bg = "#C1AB8C" )
lbl_color.place(x =170 , y = 180 )
lbl_feedback = Label(win , text = '' , font = 'arial 12 bold' , bg = "#C1AB8C")
lbl_feedback.place(x = 190, y = 270)
#================================entry========================================
ent = Entry(win , font = 'arial 17' ,  width = 20)
ent.place(x = 105 , y = 240)
#================================frame========================================
frame_tip =LabelFrame(win , text='Tips' , font=('Arial',12 , 'bold') ,width=370 , height=180 , bg = "#C1AB8C" , fg = "#B80000")
frame_tip.place(x = 89 , y = 300)
lbl_welcome = Label (frame_tip , text = f'\u2b55Welcome to COLOR GAME.   ' '\n\u2b55The game starts with ENTER.\n\u2b55The game stops with SPACE.\n\u2b55The game closes with ESC.   '   '\n\u2b55Answer them all,you will win. ''\n\u2b55You only have 45 seconds.'"\U0001F605" , font = 'arial 15 bold' , bg = "#C1AB8C" ,fg = "#503B3B")
lbl_welcome.pack(padx = 4 , pady =3 )
#================================bind=========================================
win.bind('' , startgame)
win.bind('' , escape)
win.mainloop()
										
						 
		 
				
		
		 
	 
	1761830021 
Anonymous 
Ich habe ein Spiel mit Python Tkinter geschrieben, weiß aber nicht, dass es definitiv aufhören soll? />