<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;">David,<br><br>For output graphics, you might want to have a look at <a rel="nofollow" target="_blank" href="http://www.pygame.org/">Pygame</a>.
It is a wrapper for the SDL library. It has functionality for creating
graphics windows, drawing, sprites, etc. But what might be of interest
for you is the simple set_at(x,y) method, to set the color of
individual pixels in a window.<br><br>I have found the Pygame documentation to be pretty good.<br><br>Here is a simple example of plotting a sinewave using set_at()<br><br>#-----------------------------<br>import pygame, sys, math<br>screen = pygame.display.set_mode([640,480])<br>for x in range(0, 640):<br> y = int(math.sin(x/640.0 * 4 * math.pi) * 200 + 240)<br>
screen.set_at([x, y],[255,0,0])<br>pygame.display.flip()<br>while True:<br> for event in pygame.event.get():<br> if event.type == pygame.QUIT:<br> sys.exit()<br>#------------------------------<br><br>Warren Sande<br><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: David MacQuigg <macquigg@ece.arizona.edu><br>To: edu-sig@python.org<br>Sent: Monday, March 10, 2008 10:28:21 PM<br>Subject: [Edu-sig] Introducing Python to Engineering Students<br><br>I've
been
asked
to
give
an
intro
to
Python
for
a
freshman
class
with
150
students
at
University
of
Arizona.
The
class
is
taught
in
the
Electrical
and
Computer
Engineering
Department,
and
is
titled
Computer
Programming
for
Engineering
Applications.
The
language
is
C
(Hanly
&
Koffman,
Problem
Solving
and
Program
Design
in
C).<br><br>I
think
a
nice
way
to
do
this
will
be
an
application
where
we
can
show
the
advantages
of
both
languages
-
the
computation
of
Mandelbrot
images
<a href="http://en.wikipedia.org/wiki/Mandelbrot_set" target="_blank">http://en.wikipedia.org/wiki/Mandelbrot_set</a>.
Python
will
provide
the
high-level
"glue"
which
brings
everything
together
in
a
nice
programming
environment,
and
C
will
provide
the
raw
power
for
the
loop
that
actually
computes
the
pixels.
My
initial
tests
show
this
loop
running
about
100
times
faster
in
C
than
in
Python. <br><br>The
challenge
is
to
do
this
without
overwhelming
the
students.
The
plan
is
to
make
everything
as
simple
as
possible,
just
follow
the
instructions,
except
the
loop
itself,
which
the
students
will
write
in
C,
based
on
what
I
have
written
in
Python.
See
<a href="http://ece.arizona.edu/%7Eedatools/ece175/projects/mandelbrots/mbrotHW.html" target="_blank">http://ece.arizona.edu/~edatools/ece175/projects/mandelbrots/mbrotHW.html</a>.<br><br>Suggestions
are
welcome.
Has
anyone
done
something
like
this
before?
Can
you
improve
on
my
code
(I'm
not
a
Python
expert),
or
even
suggest
something
entirely
different?<br><br>There
is
one
major
piece
I
would
like
to
add
to
what
I
have
so
far
-
output
graphics.
This
demo
would
really
be
cool
if
the
students
could
see
these
glorious
images
appear
on
their
screen
instead
of
an
array
of
numbers.
I
looked
at
the
Python
Imaging
Library
<a href="http://www.pythonware.com/products/pil/index.htm" target="_blank">http://www.pythonware.com/products/pil/index.htm</a>,
and
I
don't
see
any
examples
that
I
can
work
from
in
converting
an
array
of
numbers
into
an
image,
just
a
lot
of
dense
reference
material
that
assumes
I
already
know
these
image
data
formats.
Maybe
there
is
a
simpler
way.
Help
from
someone
with
experience
in
Python
graphics
would
be
most
appreciated.<br><br>--
Dave <br><br><br><br>_______________________________________________<br>Edu-sig
mailing
list<br><a ymailto="mailto:Edu-sig@python.org" href="mailto:Edu-sig@python.org">Edu-sig@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/edu-sig" target="_blank">http://mail.python.org/mailman/listinfo/edu-sig</a><br></div><br></div></div></body></html>