[Tutor] How do I make Python draw?
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Wed Jul 27 23:04:30 CEST 2005
On Wed, 27 Jul 2005, Nathan Pinno wrote:
> How do I make Python draw a shape? e.g. a triangle Is there a specific
> module that I have to call, or what is the command(s)?
Hi Nathan,
If you'd like to start doing graphical stuff, you might want to look at
the Tkinter module.
http://www.python.org/doc/lib/module-Tkinter.html
There's an introduction to it here:
http://www.pythonware.com/library/tkinter/introduction/
Just to whet your appetite, here's a quick-and-dirty demo program that
should draw a triangle for you:
######
"""Draws a triangle on a Tkinter canvas."""
from Tkinter import *
canvas = Canvas()
canvas.create_polygon([(1, 1), (1, 200), (100, 100)])
canvas.pack()
canvas.update_idletasks()
######
If you want to do more sophisticated graphics stuff, there are alternative
packages, like pygame:
http://www.pygame.org/news.html
If you have more questions, please feel free to ask!
More information about the Tutor
mailing list