How to make transparent windows in processing.py

Hi!
I’ve been learning to code in Processing.py and was wondering if it’s possible to make a window completely transparent in the python version of processing. I’ve seen a few similar posts such as this one but they all use JFrame which is only for java.

Thanks in advance!

Hi @Boxit379,

Welcome to the forum! :wink:

Take a look at this Processing.py documentation page:

Since Processing.py uses Jython, you should have similar APIs and function names:

With a little bit of exploration I came up with this code:

from javax.swing import JFrame
from com.sun.awt import AWTUtilities

def setup():
    size(500, 500)
    
    frame = this.surface.getNative().getFrame()

    frame.removeNotify()
    frame.setUndecorated(True)
    AWTUtilities.setWindowOpacity(frame, 0.5)
    frame.addNotify()
    
def draw():
    background(255, 0, 0)
    circle(width / 2, height / 2, width)
    noLoop()

the whole window is transparent and has a little border bug thought :wink:

3 Likes