import pygame import time pygame.init() pygame.font.init() font = pygame.font.SysFont('Arial', 40, bold=True) screen = pygame.display.set_mode((300, 300)) clock = pygame.time.Clock() running = True start_button = pygame.image.load('start.png') pause_button = pygame.image.load('pause.png') stop_button = pygame.image.load('stop.png') subsurface = pygame.Surface((300, 300)) subsurface.fill("white") start_button_blit = subsurface.blit(start_button, (50, 225)) pause_button_blit = subsurface.blit(pause_button, (125, 225)) stop_button_blit = subsurface.blit(stop_button, (200, 225)) gecen_zaman = 0 basladi = False while running: screen.blit(subsurface, (0,0)) for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.MOUSEBUTTONDOWN: if start_button_blit.collidepoint(pygame.mouse.get_pos()): if not basladi: print("Başlat düğmesi") basladi = True onceki_zaman = time.time() elif pause_button_blit.collidepoint(pygame.mouse.get_pos()): print("Puase düğmesi") basladi = False elif stop_button_blit.collidepoint(pygame.mouse.get_pos()): print("Stop düğmesi") basladi = False gecen_zaman = 0 if basladi: gecen_zaman += time.time() - onceki_zaman onceki_zaman = time.time() m, s = divmod(gecen_zaman, 60) h, m = divmod(m, 60) time_str = '{0:02d}:{1:02d}:{2:04.1f}'.format(int(h), int(m), s) time_str_surface = font.render(time_str, True, (255, 0, 0)) screen.blit(time_str_surface, (50,70)) pygame.display.flip() clock.tick(60) pygame.quit()