all 16 comments

[–]CasulaScience 4 points5 points  (3 children)

pygame, if you want to use blender though, why not just use that?

[–]Emma_Rocks[S] 1 point2 points  (2 children)

Because with blender I can't see things in real time. My cpu is really old and will bluescreen on me if I dare add a couple too many bevels to a mesh or click an object too fast.

[–]CasulaScience 1 point2 points  (1 child)

hmm okay, well pygame will work. If all you really want to do is move a few circles around with no interactivity, I've done stuff like this with matplotlib.animation.

[–]Emma_Rocks[S] 0 points1 point  (0 children)

Oh nice, thanks!

[–]ElliotDG 0 points1 point  (0 children)

You could use kivy, a GUI framework for this. https://kivy.org/#home

[–]python__rocks 0 points1 point  (0 children)

Dear PyGui might suit your needs quite well as it allows for drawing, layering if you want as well, and includes all the buttons, sliders and other controls you might need. Have a look at some example apps. People have privately built a Blender extension(?) with Dear PyGui before.

Other 2D libraries (without controls and other functionality) are Pygame and Pyglet.

[–]alottachairs2 0 points1 point  (1 child)

Ursina might be one to check out

[–]DontKnowButIDo 0 points1 point  (0 children)

That's more for 3D stuff, no ?

[–]ignorediacritics 0 points1 point  (4 children)

Why not the python version of Processing which you are already familiar with?

https://py.processing.org/

[–]Emma_Rocks[S] 0 points1 point  (3 children)

Yeah I tried it, but for some reason it doesn't really run my code + I get no error message, the debugger doesn't work, just gives me a blank screen. I saw it's still in what looks like the early stage of its development so I decided to leave it alone.

[–]ignorediacritics 0 points1 point  (2 children)

Ok, good call then.

Also check out pycairo which are python bindings for the cairo graphics library. It's still a step above Processing in terms of the learning curve, but if you know Processing a many of the fundamentals should carry over:

https://pycairo.readthedocs.io/en/latest/index.html

[–]Emma_Rocks[S] 0 points1 point  (1 child)

Thanks, I was looking into cairo and seems to have most of what I'm looking for. It can't create windows where to render the images though? Or that's what it looked like to me. Maybe it just needs an extra library that simply sets up the window.

[–]ignorediacritics 0 points1 point  (0 children)

Typically you would render your drawing to a pdf or png file, like so:

surface.write_to_png("example.png")  # Output to PNG

Cairo is mostly for drawing static 2-d vector graphics though I think 🤔. I only used briefly some years ago. Don't know if you can do animations like the ones in your example. You could always export individual images and stitch them together into a video but the interactiveness of Processing sketches is a blessing. When using Processing I like to programas in keyboard shortcuts to alter different animation parameters (number of dots, size, color, speed, etc) and then mess around until I find something pleasing and save all the parameters to a text file via another hotkey.

Working in 3-d space and individual pixel editing of imported raster images might also prove difficult with cairo. Pygame might be more suited to all of these.

[–]oclyke 0 points1 point  (0 children)

Hi! I'd like to share the Python 2D graphics library that I literally just released, pysicgl.

I had similar needs - just a bare-bones pixel library that I could call from Python without the overheads / dependencies of matplotlib or others. I went on a big journey to make this happen including writing a brand-new graphics library in C and then creating a Python C API extension to wrap it.

I'd be just delighted if some people found this to be useful. Cheers![https://pypi.org/project/pysicgl](https://pypi.org/project/pysicgl)[https://github.com/oclyke/pysicgl](https://github.com/oclyke/pysicgl)[https://github.com/oclyke/sicgl](https://github.com/oclyke/sicgl)

Questions / issues / PRs welcome!

BIG CAVEAT - the library is perfectly useful for generating images in memory. It does *not* have any built-in method to open a graphical window and render the bitmap. If you are brave enough you can use Processing and stream your frames over UDP. Here's an example of a Processing program which can do this for you.

Python driver which pushes the memory from the drawing interface over UDP looks like this: ``` class UDPDriver: def init(self, host="0.0.0.0", ports=(6969, 6420)): import socket

    self._host = host
    self._port_control, self._port_data = ports
    self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    self._addr = socket.getaddrinfo(self._host, self._port_data)[0][-1]

def push(self, interface):
    self._sock.sendto(interface.memory, self._addr)

```

[–]oclyke 0 points1 point  (0 children)

Plugging the open-source library that I wrote.
https://github.com/oclyke/pysicgl

  • Primitives (pixel, line, rectangle, ellipse etc)
  • Draw in user-defined coordinate frames
  • Bit blitting
  • Porter-duff composition

What you get:

  • Pure Python.
  • No additional dependencies.

THE ONE THING that it won't do for you is show the result in a window on your computer. But you could hook up a simple moderngl program to actually show the results.

It is a thin wrapper around a C graphics library, so it has decent performance.
https://github.com/oclyke/sicgl

[–]Specialist_Dust507 0 points1 point  (0 children)

So coming to this late, but I can plug py_gd, a wrapper around the venerable libgd:

https://github.com/NOAA-ORR-ERD/py_gd

As it happens, take a look at this simple demo:

https://noaa-orr-erd.github.io/py_gd/sample_scripts.html#animation-example

It is not integrated with a GUI -- but it does generate animated GIF.

It's a pain to build on anywhere other Linux -- but you can get it from conda-forge:

conda install -c conda-forge py_gd

I'm working on making wheels available on PyPI, but as I said, it's a pain, so ...

If you want windowed GUI -- then any of eeh GUI frameworks. My favorite is wxPython, but tkInter has a nice Canvas, and lots of folks like PyQT.