Promoting Python

Gregory Ewing greg.ewing at canterbury.ac.nz
Wed Apr 6 04:52:53 EDT 2016


Another option for graphical stuff is pygame:

http://pygame.org/news.html

A rough translation of some of your code:

import pygame, sys
from pygame import display, draw, event, font, Color, QUIT

# Set up the display window
screen = display.set_mode((800, 600))

colors = ["red", "orange", "yellow", "green", "blue", "purple"]

font.init()
f = font.Font(None, 24)
y = 10
for name in colors:
     text = f.render("Color " + name, True, Color(name))
     screen.blit(text, (10, y))
     y += text.get_height()

x = 30
y = 200
for name in colors:
     c = Color(name)
     draw.circle(screen, c, (x, y), 20)
     x += 50

# Refresh the screen
display.flip()

# Pause until the window is closed
while True:
     for e in event.get():
         if e.type == QUIT:
             sys.exit(0)

-- 
Greg



More information about the Python-list mailing list