I teach college classes in Python.  I currently teach Intro to Python at two 
different colleges in Silicon Valley (California).

For about the last two years, I have been working on the development of a new 
course (and book).  The goal is to teach Object-Oriented Programming using 
Python and Pygame.  To this end, I have been working on the development of two 
packages that implement of a number of common user interface and other elements 
that my students can use to build Pygame-based games (and other programs).  The 
idea is that if I supply GUI "widgets" and other often-used classes and 
functions, then my students can concentrate on building the core of their 
projects.  Some of my more advanced students have been using these packages for 
a while in their final projects of my Intro to Python course, and I look 
forward to working through the details of how they are built in my new OOP 
course.

I am announcing them here in the hopes that people will try them out can give 
me feedback about their usefulness.  All code is in Python 3.

There are two packages:


pygwidgets - a number of graphical user interface widgets, each implemented as 
a class.  This package includes:
- Animation - shows a list of images in order with timing
- CustomButton - standard button built from supplied custom artwork
- CustomCheckBox - standard check box built from supplied custom artwork
- CustomRadioButton - standard radio button built from supplied custom artwork
- DisplayText - for displaying text in a window
- Dragger - to drag an image around a window
- Image - displays an image in a window
- ImageCollection - a collection of images, any of which can be displayed at 
any time
- InputText - a field where the user can type
- SpriteSheetAnimation - animation class that uses a single sprite sheet
- TextButton - standard button built from a string of text
- TextCheckBox - standard check box built from a string of text
- TextRadioButton - standard Radio button built from a string of text

Full documentation is available at:  
https://pygwidgets.readthedocs.io/en/latest/ 
<https://pygwidgets.readthedocs.io/en/latest/>   One of the main goals was to 
make the calling sequences of these classes very similar.  The package was 
inspired by "PygButton" written by Al Sweigart.  I decided to split that into 
TextButton (where it builds a button based just on a text string) and 
CustomButton (where programmers could use their own art, because most of my 
students are art students).  The package grew from there to include other 
elements as they were requested or I found the need for them in my programs.


pyghelpers - a collection of classes and functions for use with Pygame 
programs.  Classes are:
- CountDownTimer - A timer that counts down from a starting point
- CountUpTimer - A timer that counts up from zero
- Scene - a base class for a scene managed by the SceneMgr
- SceneMgr - allows for a Pygame program to have multiple scenes, and 
communicate between scenes
- Timer - a simple timer

  (additional functions in pyghelpers)
- closeFile - closes an already opened file
- customAnswerDialog - a dialog box built using custom artwork that allows the 
user to type an answer and select yes/no, OK/Cancel, etc
- customYesNoDialog - a dialog box built using custom artwork that displays a 
message and allows the user to select yes/no, OK/Cancel, etc.
- fileExists - find out if a file at a given path exists
- openFileForReading - opens a file for reading
- openFileForWriting - opens a file for writing
- readALine - reads a single line of text from an opened file
- readFile - reads the full contents of a file
- textAnswerDialog - a dialog box built from TextButtons (see pygwidgets) that 
allows the user to type an answer and select yes/no, OK/Cancel, etc.
- textYesNoDialog - a dialog box built from TextButtons (see pygwidgets) that 
displays a message and allows the user to select yes/no, OK/Cancel, etc.
- writeALine - writes a single line of text to a file
- writeFile - writes to a text file

Full documentation is available at:  
https://pyghelpers.readthedocs.io/en/latest/ 
<https://pyghelpers.readthedocs.io/en/latest/>


Both packages are available on PyPI.  They can be downloaded and installed with 
pip (I use pip3 because I have Python 2 and Python 3 installed on my system):


  pip3 install pygwidgets -U --user

  pip3 install pyghelpers -U --user


I have done extensive testing all this with Python 3.6.1 and Pygame 1.9.3 on 
both Mac and Windows.   Some of my students have also done some testing with 
Python 3.7 and Pygame 1.9.4.  

This is my first attempt at doing Python packaging, and to be honest, I found 
it extremely painful.  Because this part was all new to me, I have literally 
spent months working on the packaging, documentation (ReadTheDocs), git, 
GitHub, posting to PyPI, etc.  But I believe (hope) that it is finally working 
correctly.  

The above commands should install "pygwidgets" and "pyghelpers" into the user's 
site-packages folder.  I use them in my programs by just using a simple import:

   import pygwidgets
   import pyghelpers     

The pygwidgets installation also installs the following test program in the 
user's site-packages folder: 

   site-packages/pygwidgets/pygwidgets_test/Main_Test_pygwidgets.py             
         <- shows off many of the capabilities of pygwidgets

The pyghelpers installation places two test programs in the user's 
site-packages folder:

   site-packages/pyghelpers_test/DialogTester/Main_DialogTester.py              
           <- demonstrates how to use dialog box code
   site-packages/pyghelpers_test/Dodger/Main_Dodger.py                          
               <- full game that demonstrates many capabilities of pygwidgets 
and pyghelpers
                                                                                
                                                  an object-oriented version of 
Al Sweigart's game (with his permission)

I have built a number of small games using these two packages.  If people are 
interested, I could upload more example games.

I typically build/run these programs using either IDLE or PyCharm.  I never use 
the command line for running Python, but if you set your path to these folders, 
they should run just fine that way too.

I look forward to any feedback.


Happy Holidays,

Irv

Reply via email to