Skip to content

Instantly share code, notes, and snippets.

@PMaynard
Created June 26, 2014 11:08
Show Gist options
  • Save PMaynard/17b9668353bc9ee2428f to your computer and use it in GitHub Desktop.
Save PMaynard/17b9668353bc9ee2428f to your computer and use it in GitHub Desktop.
Simple Clock
import pygame
from pygame.locals import *
import sys
from time import gmtime, strftime
pygame.init()
font = pygame.font.Font(None, 30)
screen = pygame.display.set_mode(font.size("XX:XX:XX"))
background = pygame.Surface(screen.get_size() )
def update():
background.fill((0,0,0))
background.blit( font.render(strftime("%H:%M:%S", gmtime()), 1, (255,0,0)), (0,0))
screen.blit(background, (0,0))
pygame.display.update()
while 1:
for event in pygame.event.get():
if event.type in (QUIT, KEYDOWN):
sys.exit()
update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment