38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import argparse
|
|
import pygame
|
|
import sys
|
|
import time
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Display a fullscreen message.")
|
|
parser.add_argument('--message', type=str, default="Hello, Adolfo!", help='Message to display')
|
|
parser.add_argument('--timeout', type=int, default=0, help='Seconds before auto-dismiss (0 = wait for key)')
|
|
args = parser.parse_args()
|
|
|
|
pygame.init()
|
|
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
|
|
pygame.display.set_caption("Fullscreen Message")
|
|
font = pygame.font.Font(None, 100)
|
|
text = font.render(args.message, True, (255, 255, 255))
|
|
text_rect = text.get_rect(center=(screen.get_width() // 2, screen.get_height() // 2))
|
|
clock = pygame.time.Clock()
|
|
start_time = time.time()
|
|
running = True
|
|
|
|
while running:
|
|
for event in pygame.event.get():
|
|
if event.type in (pygame.QUIT, pygame.KEYDOWN, pygame.MOUSEBUTTONDOWN):
|
|
running = False
|
|
if args.timeout and (time.time() - start_time) > args.timeout:
|
|
running = False
|
|
|
|
screen.fill((0, 0, 0))
|
|
screen.blit(text, text_rect)
|
|
pygame.display.flip()
|
|
clock.tick(30)
|
|
pygame.quit()
|
|
sys.exit()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|