[Python] Pyglet overlay/transparent style not transparent

Discussão em 'Python' iniciado por Stack, Junho 18, 2025.

  1. Stack

    Stack Membro Participativo

    When I run the program, the window (top right and bottom left) is supposed to be transparent but instead, it is black

    Here is an image of a lilac window, with a grey line around the bottom and right edge, black, opaque squares on the bottom left and top right: [​IMG]

    There are no warning or errors in the console

    Here is the code I used:

    import pyglet
    from pyglet.window import *

    win = Window(width=650, height=370, style=Window.WINDOW_STYLE_OVERLAY, resizable=False)
    screen = win.display.get_default_screen()
    win.set_location((screen.width//2 - win.width//2) + 5, (screen.height//2 - win.height//2) + 5)

    @win.event
    def on_draw():
    win.clear()
    shadow = pyglet.shapes.Rectangle(x=10, y=0, width=win.width - 10, height=win.height - 10, color=(100, 100, 100, 100))
    shadow.draw()
    background = pyglet.shapes.Rectangle(x=0, y=10, width=win.width - 10, height=win.height - 10, color=(150, 100, 255))
    background.draw()

    pyglet.app.run()


    Extra context:

    Python 3.12, latest pyglet version, Windows 11, and on PyCharm

    I tried using python 3.8, the Window.WINDOW_STYLE_TRANSPARENT style, updating my drivers, changing the objects, and more, but nothing worked

    Continue reading...

Compartilhe esta Página