'Python3.10, Text Doesn't Show On Pygame Window
I am trying to make a app where you enter in the minute value then a timer pops up on a window. The timer isnt appearing. I am using python 3.10. I'm new to python so please if you can fix it, please include the source code.
import pygame
import time
import sys
pygame.init()
q = True
WIDTH = 800
HEIGHT = 600
clock = pygame.time.Clock()
myFont = pygame.font.SysFont("monospace", 35)
def countdown(t):
t *= 60
while t:
min, sec = divmod(t, 60)
timer = '{:02d}:{:02d}'.format(min, sec)
#
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('PyTimerTwo, By: ChanceMeteor515')
screen.fill((0, 0, 0))
text = str(timer)
label = myFont.render(text, 1, (255, 255, 255))
screen.blit(label, (WIDTH - 200, HEIGHT - 40))
#
print("\nTime's Up")
time.sleep(5400)
t = input("Enter Time In Minutes:")
countdown(int(t))
while q:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_h:
pygame.mouse.set_visible(0)
elif event.key == pygame.K_ESCAPE:
sys.exit()
clock.tick(120)
pygame.display.update()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
