[Tutor] graphics library for teaching Python

2018-12-21 Thread Michael Mossey
I'm a computer science tutor and I'm asking advice about a graphics or game
library that can be used with Python effectively for teaching purposes.

I've found that having my student pick a long-term project is a good way
for them to learn coding, and graphics or games make great projects that
both have stimulating results and bring computer-science-y topics into the
mix (i.e. they are natural vehicles for OO, data structures, and
algorithms).

There are two sub-topics I'm interested in - (1) graphics, as in drawing
interesting pictures or art, or using diagrams for data visualization. (2)
Simple games, with the use of sprites.

I've been using PyGame, but I'm not happy with it. It's not very well
organized or documented, and not very capable of general graphics.

So I'm looking into a few other possibilities. No library can be everything
to everyone, but I'd  like something that gives students exposure to a
variety of programming tasks, like constructing GUIs, events and event
loops, and 2-D graphics via stroking and filling common polygon shapes and
Bezier curves. (3D is not necessary for now.)

Here are some alternatives to PyGame:

- Pyglet. Doesn't look promising. I'm mainly interested in 2D, and I don't
see common data visualization tasks provided like filling and stroking
Bezier curve shapes (maybe I'm missing something).

- Cairo. Looks great for static 2D graphics, but not games .. again maybe
I'm missing something.

- Cocos2D. Good for games but not necessary general 2D graphics.

- PyQt. I used this extensively at my last regular desk job many years ago,
and if I recall it has the QCanvas element with pretty deep graphics
ability and also event handling. It has collision detection too, I think,
allowing for easy 2D game writing.

It looks to me like PyQt is the most capable program and most related to
what I want to do, but one thing I'm wondering about is how widely its used
and whether it would be good exposure for students to connect them to the
wider world of computing they will someday enter.

Any thoughts would be appreciated.

Mike
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Alan Gauld via Tutor
On 21/12/2018 04:16, Michael Mossey wrote:
> I'm a computer science tutor and I'm asking advice about a graphics or game
> library that can be used with Python effectively for teaching purposes.

I'll start by saying that Python is not the berst programming language
for graphics. However there are some other options beyond those you mention:

> There are two sub-topics I'm interested in - (1) graphics, as in drawing
> interesting pictures or art, or using diagrams for data visualization. 

The turtle module gives a basic intro yto drawing shapes and
introduces an interesting alternative to traditional cartesian
coordinate geometry.

The Tkinter module includes a Canvas widget that supports graphic primitives

The gnuplot and matplotlib packages allow plotting of data.
Neither is in the standard library but can be easily installed.

The SciPy bundle comes with a neat tool for visualisaton
which might be useful. Especially for older students with a
knowledge of math - you don't specify the target age group.

Finally Dabo includes a graphical GUI builder and database
integration. I haven't used it for several years so I'm not
sure on its current development status but it seemed to work
well when I tried it.

(2) Simple games, with the use of sprites.

I'm not much of a games person so I'll leave others to comment.

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Cranky Frankie
Tutor@python.org:
"I'm a computer science tutor and I'm asking advice about a graphics or game
library that can be used with Python effectively for teaching purposes."

Michael Dawson's "Python Programming for Absolute Beginners" uses PyGame.
Might be worth a look.



On Fri, Dec 21, 2018 at 3:26 AM Michael Mossey 
wrote:

> I'm a computer science tutor and I'm asking advice about a graphics or game
> library that can be used with Python effectively for teaching purposes.
>
> I've found that having my student pick a long-term project is a good way
> for them to learn coding, and graphics or games make great projects that
> both have stimulating results and bring computer-science-y topics into the
> mix (i.e. they are natural vehicles for OO, data structures, and
> algorithms).
>
> There are two sub-topics I'm interested in - (1) graphics, as in drawing
> interesting pictures or art, or using diagrams for data visualization. (2)
> Simple games, with the use of sprites.
>
> I've been using PyGame, but I'm not happy with it. It's not very well
> organized or documented, and not very capable of general graphics.
>
> So I'm looking into a few other possibilities. No library can be everything
> to everyone, but I'd  like something that gives students exposure to a
> variety of programming tasks, like constructing GUIs, events and event
> loops, and 2-D graphics via stroking and filling common polygon shapes and
> Bezier curves. (3D is not necessary for now.)
>
> Here are some alternatives to PyGame:
>
> - Pyglet. Doesn't look promising. I'm mainly interested in 2D, and I don't
> see common data visualization tasks provided like filling and stroking
> Bezier curve shapes (maybe I'm missing something).
>
> - Cairo. Looks great for static 2D graphics, but not games .. again maybe
> I'm missing something.
>
> - Cocos2D. Good for games but not necessary general 2D graphics.
>
> - PyQt. I used this extensively at my last regular desk job many years ago,
> and if I recall it has the QCanvas element with pretty deep graphics
> ability and also event handling. It has collision detection too, I think,
> allowing for easy 2D game writing.
>
> It looks to me like PyQt is the most capable program and most related to
> what I want to do, but one thing I'm wondering about is how widely its used
> and whether it would be good exposure for students to connect them to the
> wider world of computing they will someday enter.
>
> Any thoughts would be appreciated.
>
> Mike
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


-- 
Frank L. "Cranky Frankie" Palmeri, Risible Riding Raconteur & Writer
"If you have a garden and a library, you have everything you need." - Cicero
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Adam Eyring
On Fri, Dec 21, 2018, 3:26 AM Michael Mossey 
wrote:

>
> There are two sub-topics I'm interested in - (1) graphics, as in drawing
> interesting pictures or art, or using diagrams for data visualization. (2)
> Simple games, with the use of sprites.
>

One that hasn't been mention in yours and Alan's lists is Arcade. Developed
in recent years by a Simpson College professor, he's been using it for
teaching game development. Supports a lot of features you're asking for and
I've been enjoying playing with it.
Http://arcade.academy
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Mike Barnett
>There are two sub-topics I'm interested in - (1) graphics, as in drawing 
>interesting pictures or art, or using diagrams for data visualization. (2) 
>Simple games, with the use of sprites.

Can you post some images of similar programs / graphics you are wanting to 
create?  It would be extremely helpful to see concrete "targets".  Then I can 
better inform you if PySimpleGUI is capable of doing what you seek.

I've recently been writing more games using PySimpleGUI to see what's missing 
in the SDK, to determine new features that will help developers.

For data visualization, there's Matplotlib and Pyplot, both integrate with 
PySimpleGUI very well.  Someone mentioned Turtle, it too integrates well by 
using a tkinter canvas.

I've been doing simple graphs by using the drawing primitives and games using 
images that I often include in the source code.  The Uno Game for example has 
all of the cards included in the .py file.

Some examples:

Bar chart:
https://gist.github.com/MikeTheWatchGuy/fd79baad627ae879bb74437427ad4ff0

Simple Matplotlib:
https://gist.github.com/MikeTheWatchGuy/33579888cd976e2ef0231869bba38bb4

Simple plotting - sine wave:
https://gist.github.com/MikeTheWatchGuy/397b681d1b3863a74936724fdfd1ea34

Scrolling bar chart:
https://user-images.githubusercontent.com/13696193/47611749-18964c80-da42-11e8-93c4-6821a6fce488.gif

Matplotlib integration:
https://user-images.githubusercontent.com/13696193/50046965-cb664c80-007a-11e9-9470-b7d1ab3fa20e.gif


Some simple games

Conway's Game of Life:
https://user-images.githubusercontent.com/13696193/50244709-9e79a880-039e-11e9-9b51-733357a87c68.gif

Uno Card Game:
https://user-images.githubusercontent.com/13696193/49945232-67952580-feba-11e8-90c8-7dc31c5f7c67.gif

Turtle:
https://user-images.githubusercontent.com/13696193/49346588-b644f300-f662-11e8-8c83-44c74aedf89f.gif

A Crossword Puzzle GUI:
https://user-images.githubusercontent.com/13696193/47968340-98ba4480-e036-11e8-9d44-8a39ac174533.jpg

Chess GUI:
https://user-images.githubusercontent.com/13696193/47380967-b6012180-d6cc-11e8-946d-a646921fb8d0.gif


These are all tkinter based examples. 

While PySimpleGUI does have a Qt port, it's not as complete when it comes to 
these graphics primitives and integration with Matplotlib.


-mike

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Michael Mossey
On Fri, Dec 21, 2018 at 9:15 AM Mike Barnett 
wrote:

> >There are two sub-topics I'm interested in - (1) graphics, as in drawing
> interesting pictures or art, or using diagrams for data visualization. (2)
> Simple games, with the use of sprites.
>
> Can you post some images of similar programs / graphics you are wanting to
> create?  It would be extremely helpful to see concrete "targets".  Then I
> can better inform you if PySimpleGUI is capable of doing what you seek.
>

I think PySimpleGUI might be a great fit.

I'm getting my ideas from projects way in the past, so I can't easily find
screenshots. But what I'm looking for is pretty easy to describe.

for graphics: "Capabilities similar to JavaScript canvas plus collision
detection."

In other words, basic text filling/stroking, basic shape and line and
Bezier curve filling/stroking, and then collision detection to make simple
games easier.

for GUIs: "Basic dialogs, buttons, labels, checkboxes, and integrated
canvas."

My students range a lot in age and ability. Youngest is 9th grade, ranging
upward to professionals who are looking to learn programming as a new skill
to use in the workplace or put on their resume.



>
> I've recently been writing more games using PySimpleGUI to see what's
> missing in the SDK, to determine new features that will help developers.
>
> For data visualization, there's Matplotlib and Pyplot, both integrate with
> PySimpleGUI very well.  Someone mentioned Turtle, it too integrates well by
> using a tkinter canvas.
>

By data visualization, I don't mean necessarily plotting. Matplotlib might
be an awkward fit.

I'm thinking of visualizing math processes, algorithms, and so forth. Say,
we animate a cubic curve changing shape while the coefficients change. Or
we animate the inner workings of a tic tac toe strategy algorithm by having
it draw a tic tac toe board with changing colors or shapes to represent
positions or calculations in progress. I don't mean something really
complicated. Just picture the simplest thing that makes sense.

Thanks for the other links to examples.

Mike
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Mike Barnett
For PySimpleGUI….
Things like “collision detection” are up to the application.  PySimpleGUI gives 
you ability to place “objects” at x,y coordinates.  The primitives allow 
images, circles, lines, rectangles, arcs, and text to be drawn and removed.  If 
one overlaps another you’re on the hook for determining that.

GUIs
PySimpleGUI rocks for doing custom GUIs.  At last count there were 28 widgets 
that you can place pretty much anywhere within a window.  These are the basic 
widgets (buttons, listbox, checkbox, radio button, etc.) as well as advanced 
Panes and Button-Menus.  It’s excellent for teaching GUIs and how to layout a 
GUI because all of the widgets are available for the developer, not a subset.

You can run sync and async event loops so doing things like polling hardware 
devices is easy.  No callbacks to worry about.
Here’s a description of the architecture
https://pysimplegui.readthedocs.io/architecture/

Determining which button was clicked is as easy as a comparison:
if button == ‘Download’:
   do_download_stuff()

Animation is a super easy to do as all you’re doing is showing images in a loop.

Here’s a program that does a simple graph of a math function that allows you to 
change the variables using a couple of sliders.  It demonstrates the “graphing” 
capability.
https://gist.github.com/MikeTheWatchGuy/8453e82fc65e24060775443e843ab80b


One big drawback for tkinter / PySimpleGUI is the inability to have an image as 
the background.  You can have an image for the background of a canvas, but of 
the entire window.  For that you’ll need to use PySimpleGUIQt.

Anyway, it’s worth a look to see if it fits some of your needs.


@mike

From: Michael Mossey 
Sent: Friday, December 21, 2018 1:40 PM
To: Mike Barnett 
Cc: tutor@python.org
Subject: Re: [Tutor] graphics library for teaching Python



On Fri, Dec 21, 2018 at 9:15 AM Mike Barnett 
mailto:mike_barn...@hotmail.com>> wrote:
>There are two sub-topics I'm interested in - (1) graphics, as in drawing 
>interesting pictures or art, or using diagrams for data visualization. (2) 
>Simple games, with the use of sprites.

Can you post some images of similar programs / graphics you are wanting to 
create?  It would be extremely helpful to see concrete "targets".  Then I can 
better inform you if PySimpleGUI is capable of doing what you seek.

I think PySimpleGUI might be a great fit.

I'm getting my ideas from projects way in the past, so I can't easily find 
screenshots. But what I'm looking for is pretty easy to describe.

for graphics: "Capabilities similar to JavaScript canvas plus collision 
detection."

In other words, basic text filling/stroking, basic shape and line and Bezier 
curve filling/stroking, and then collision detection to make simple games 
easier.

for GUIs: "Basic dialogs, buttons, labels, checkboxes, and integrated canvas."

My students range a lot in age and ability. Youngest is 9th grade, ranging 
upward to professionals who are looking to learn programming as a new skill to 
use in the workplace or put on their resume.



I've recently been writing more games using PySimpleGUI to see what's missing 
in the SDK, to determine new features that will help developers.

For data visualization, there's Matplotlib and Pyplot, both integrate with 
PySimpleGUI very well.  Someone mentioned Turtle, it too integrates well by 
using a tkinter canvas.

By data visualization, I don't mean necessarily plotting. Matplotlib might be 
an awkward fit.

I'm thinking of visualizing math processes, algorithms, and so forth. Say, we 
animate a cubic curve changing shape while the coefficients change. Or we 
animate the inner workings of a tic tac toe strategy algorithm by having it 
draw a tic tac toe board with changing colors or shapes to represent positions 
or calculations in progress. I don't mean something really complicated. Just 
picture the simplest thing that makes sense.

Thanks for the other links to examples.

Mike


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor