Вы вызываете screen.blit(cocd, (450, 600)) внутри цикла событий. import pygame
from pygame.locals import *
pygame.init()
def in_int(num, base):
n = int(str(num), base)
return n
# Установка размеров окна
screen = pygame.display.set_mode((1400, 700))
pygame.display.set_caption("Калькулятор систем счисления")
input_box1 = pygame.Rect(292, 100, 250, 32)
input_box2 = pygame.Rect(650, 100, 140, 32)
input_box3 = pygame.Rect(880, 100, 140, 32)
button = pygame.Rect(600, 200, 200, 50)
color_inactive = pygame.Color(140, 140, 140)
color_active = pygame.Color(220, 220, 220)
color1 = color_inactive
color2 = color_inactive
color3 = color_inactive
active1 = False
active2 = False
active3 = False
nums_of_user = ''
base_of_user = ''
required_base = ''
show_result = False
font = pygame.font.Font(None, 38)
explanation = font.render('Перевести (число)', True, (255, 255, 255))
explanation1 = font.render('из (СС)', True, (255, 255, 255))
explanation2 = font.render('в (СС)', True, (255, 255, 255))
result = font.render('Результат: ', True, (255, 255, 255))
cocd = font.render("привет", True, (255, 255, 255))
clock = pygame.time.Clock()
running = True
while running:
for event in pygame.event.get():
if event.type == QUIT:
running = False
if event.type == pygame.MOUSEBUTTONDOWN:
if button.collidepoint(event.pos):
nums_of_user = int(nums_of_user)
base_of_user = int(base_of_user)
required_base = int(required_base)
bread = in_int(nums_of_user, base_of_user)
bity = format(bread, 'b')
octy = format(bread, 'o')
hexy = format(bread, 'X')
print(bity)
print(octy)
print(bread)
print(hexy)
show_result = True
if event.type == MOUSEBUTTONDOWN:
if input_box1.collidepoint(event.pos):
active1 = not active1
else:
active1 = False
if input_box2.collidepoint(event.pos):
active2 = not active2
else:
active2 = False
if input_box3.collidepoint(event.pos):
active3 = not active3
else:
active3 = False
if event.type == KEYDOWN:
if active1:
if event.key == K_BACKSPACE:
nums_of_user = nums_of_user[:-1]
else:
nums_of_user += event.unicode
if active2:
if event.key == K_BACKSPACE:
base_of_user = base_of_user[:-1]
else:
base_of_user += event.unicode
if active3:
if event.key == K_BACKSPACE:
required_base = required_base[:-1]
else:
required_base += event.unicode
screen.fill((62, 62, 62))
# Функции для отрисовки прямоугольников и текста
color1 = color_active if active1 else color_inactive
pygame.draw.rect(screen, color1, input_box1, 3)
font = pygame.font.Font(None, 32)
text_surface = font.render(str(nums_of_user), True, (255, 255, 255))
screen.blit(text_surface, (input_box1.x + 5, input_box1.y + 5))
color2 = color_active if active2 else color_inactive
pygame.draw.rect(screen, color2, input_box2, 3)
text_surface = font.render(str(base_of_user), True, (255, 255, 255))
screen.blit(text_surface, (input_box2.x + 5, input_box2.y + 5))
color3 = color_active if active3 else color_inactive
pygame.draw.rect(screen, color3, input_box3, 3)
text_surface = font.render(str(required_base), True, (255, 255, 255))
screen.blit(text_surface, (input_box3.x + 5, input_box3.y + 5))
screen.blit(explanation, (50, 100))
screen.blit(explanation1, (550, 100))
screen.blit(explanation2, (795, 100))
screen.blit(result, (50, 400))
pygame.draw.rect(screen, (255, 255, 255), button)
text = font.render("Конвертировать", True, (0, 0, 0))
text_rect = text.get_rect(center=button.center)
screen.blit(text, text_rect)
if show_result:
screen.blit(cocd, (450, 600))
pygame.display.flip()
clock.tick(30)
pygame.quit()