Hey everyone
I am interested in learning Pygame as a GUI that is suited to making games and i was wondering if it was worth it?
My question is, is it good for anything else than games or animations?
Hey everyone
I am interested in learning Pygame as a GUI that is suited to making games and i was wondering if it was worth it?
My question is, is it good for anything else than games or animations?
PyGame isn't very useful as a typical GUI toolkit, but if you want to have fun with images, animation, sound, video etc. it is great. Like the name says, it's a good toolkit for game development with Python.
Here is a typical example for drawing shapes:
# draw random circles with module pygame
# pygame free from: http://www.pygame.org/
import pygame as pg
import random as rn
# color rgb tuples
black = 0, 0, 0
blue = 0, 0, 255
green = 0, 255, 0
olive = 128, 128, 0
orange = 255, 165, 0
magenta = 255, 0, 255
red = 255, 0, 0
yellow = 255, 255, 0
white = 255, 255, 255
color_list = [red, blue, green, yellow, olive, orange, magenta]
# window/screen width and height
w = 500
h = 500
screen = pg.display.set_mode((w, h))
pg.display.set_caption('Draw a number of random circles')
screen.fill(black)
# draw n circles
n = 20
for k in range(n):
x = rn.randint(10, w)
y = rn.randint(10, h)
radius = rn.randint(2, h//3)
color = rn.choice(color_list)
position = x, y
# circle border width = 2
pg.draw.circle(screen, color, position, radius, 2)
# update display
pg.display.flip()
# event loop ...
running = True
while running:
for event in pg.event.get():
# quit when window corner x is clicked
if event.type == pg.QUIT:
running = False
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.