How do I stop my pygame window showing things in the background?

Viewed 9

I've recently started working on writing a FDTD simulation program for electromagnetic simulations. I thought I might use pygame for live visualisation as I haven't really seen anything that could work similarly (not to say there isn't, alternatives would be welcome).

All I have so far in regards to pygame is a simple window which is filled with black.

import sys
import pygame as pg

pg.init()

W = 900
H = 900

win_size = (W,H)

Background = pg.display.set_mode(win_size)

Background.fill((0,0,0))


while True:
    for event in pg.event.get():

        if event.type == pg.QUIT: sys.exit()

I don't receive any error messages but when I run the code and the window launches, it only shows whatever is behind it. Sometimes other windows I have open at the time also show glitches which only go away once I click on the them.

I have a feeling that this isn't a pygame issue but I'm not really sure what to do about it and can't find any other resources online that help.

Here are pictures of my system info along 1 with a visual example of what happens when I run the code2. I am using pygame v2.1.2 on python 3.8.10.

Any help would be much appreciated, thanks :)

0 Answers
Related