Change 7-segment font to a fixed width version

This commit is contained in:
Junior 2024-06-04 18:27:45 -04:00
parent d1e0e12b1a
commit 004afb7fce
2 changed files with 3 additions and 3 deletions

View File

@ -25,7 +25,7 @@ logo_text_1 = cheesy_font.render("Cheesy", True, (240, 240, 20))
logo_text_2 = cheesy_font.render("Calculator", True, (240, 240, 20))
screen.blit(logo_text_1, (width // 2 - logo_text_1.get_width() // 2 + 80, -15))
screen.blit(logo_text_2, (width // 2 - logo_text_2.get_width() // 2 + 80, 30))
sevenseg_font = pygame.font.Font(os.path.join("font", "Seven Segment.ttf"), 80)
sevenseg_font = pygame.font.Font(os.path.join("font", "DSEG7Modern-Bold.ttf"), 60)
while True:
for event in pygame.event.get():
@ -40,7 +40,7 @@ while True:
pass
elif event.type == pygame.KEYDOWN \
and ((event.key >= pygame.K_0 and event.key <= pygame.K_9) or (event.key >= pygame.K_KP1 and event.key <= pygame.K_KP0)) \
and len(str(num_display)) < 14:
and len(str(num_display)) <= 10:
if event.key == pygame.K_KP0:
actual_key = pygame.K_0
elif event.key >= pygame.K_KP1 and event.key <= pygame.K_KP9:
@ -57,6 +57,6 @@ while True:
pygame.draw.rect(screen, (0, 0, 0), pygame.Rect(12, 97, 576, 126))
num_show = (num_float == False)
text = sevenseg_font.render(str(num_display) + ".", True, (255, 255, 255))
screen.blit(text, (580 - text.get_width(), 110))
screen.blit(text, (580 - text.get_width(), 120))
pygame.draw.rect(screen, (240, 240, 20), pygame.Rect(10, 100, 580, 110), 2)
pygame.display.flip()

Binary file not shown.