PyGraphica

Check out the installation and user guides here.

If you prefer to listen to this I presented PyGraphica at PyConAu 2023. My section starts at 45:18.

PyConAU 2023 student showcase.

When I was first learning to program it took me a long time to get to the point of making functional GUIs and games (Python was my first language). It was always going to be a learning curve, but the existing Python GUI/game libraries made it all the more difficult. These libraries were very powerful, but not accessible to the level of experience I had.

Years later, I decided to do something about it. By this point I was well up to speed on the major libraries like PyGame, Kivy, and Tkinter - and so I decided to make my own library. I'd start at the base, and build everything up until I had all the tools necessary to build an app or game presented in an accessible package.

The first step was to choose a low level language to build in. Most of these are in C, so it would also need to be one with a Python wrapper. The two options which I seriously considered were OpenGL and SDL2. I experimented with both, however in the end I chose SDL2 (with the PySDL2 wrapper) as it was easier to install on both Windows and Linux, and so would produce fewer dependency issues later on.

The first part of building the library was relatively simple. After setting out the nomenclature and other conventions I created classes for:

The first four were simple. The last two were a bit more complicated. Creating an image class involved dealing with editing the image first (cropping, resizing, stretching, etc.), then creating an SDL2 image object to be displayed with each screen update. Creating a textbox class involved drawing the background rectangle, keeping track of whether the user had selected or deselected the textbox, and what key changes had occured.

After finishing all the individual classes and a few additional functions (e.g. the update function - unlike other libraries mine will update all the objects at once), I was ready to publish on PyPI. Having never done this before it took a while to sort out the bugs, but eventually it was sorted and PyGraphica was released!

I hope to continue to add functionality to PyGraphica in the future, and am currently using it to develop an app for NavCS. If you want to have a look at the code for PyGraphica you can check out the Github repo here.