Problem And Question
So I’m looking for a pretty basic library in python where I can create a window, and then draw lines and basic shapes on it. Nothing too complex, just nice and simple. I figure there’s lots of libraries out there that can do this, but I don’t know any of them. Can anyone give me some recommendations?
EDIT: Note that there are several answers describing different GUI toolkits with code snippets. Take a look at the various answers for a brief look into the various toolkits.
Best Solution And Answer
I’d definitely recommend pygame. Here is some code that does what you want:
import sys #import and init pygame import pygame pygame.init() #create the screen window = pygame.display.set_mode((640, 480)) #draw a line - see http://www.pygame.org/docs/ref/draw.html for more pygame.draw.line(window, (255, 255, 255), (0, 0), (30, 50)) #draw it to the screen pygame.display.flip() #input handling (somewhat boilerplate code): while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit(0) else: print event