My windows is not showing any thing. (pygame)

Hello,
I am trying to make a game in pygame and after i optimised my code it stopped working.
It is creating a window but it is black .

Thank you for helping.

Here is my code:

import pygame
import sys
from pygame.constants import K_RIGHT
 
pygame.init()
 
screen_width = 800
screen_hight = 600
 
game_window = pygame.display.set_mode((screen_width, screen_hight))
pygame.display.set_caption("Window")
 
walkleft = (pygame.image.load("D:\python project\pygametest\idle.png"))
walkright = (pygame.image.load("D:\python project\pygametest\idleflip.png"))
idle = (pygame.image.load("D:\python project\pygametest\eidle.png"))
bg = (pygame.image.load("D:\python project\pygametest\ibg.png"))
 
clock = pygame.time.Clock()
 
class player (object):
    def __init__(self, x, y, screen_width, screen_hight):
        self.x=x
        self.y=y
        self.screen_width=screen_width
        self.screen_hight=screen_hight
        self.vel=5
        self.is_jump=False
        self.jumpcount=10
        self.left=False
        self.right=False
        self.walkcount=0
 
    def draw(self,game_window):
        if self.walkcount +1 >= 27:
            self.walkcount = 0
         
        if self.left:
            game_window.blit(walkleft,(self.x,self.y))
            self.walkcount += 1
        elif self.right:
            self.game_window.blit(walkright,(self.x,self.y))
            self.walkcount += 1
        else:
            game_window.blit(idle, (self.x,self.y))
 
def redrawwindow():
    global walkcount
    man.draw
    pygame.display.update()
     
#mainloop
 
man=player(300 ,400,64,64)
 
game_running = True
 
while game_running:
    clock.tick(27)
     
    pygame.display.update()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            game_running = False
 
    keys = pygame.key.get_pressed()
 
    if keys[pygame.K_LEFT] and man.x > man.vel:
            man.x -= man.vel
            man.right = False
            man.left = True
    elif keys[pygame.K_RIGHT] and man.x < man.screen_width - man.vel:
            man.x += man.vel
            man.right = True
            man.left = False
    else:
        man.right = False
        man.left = False
        man.walkcount = 0
 
    if not (man.is_jump):
        if keys[pygame.K_SPACE]:
            man.is_jump = True
            man.right = False
            man.left = False
            man.walkcount = 0
 
    else:
        if man.jumpcount >= -10:
            neg = 1
            if man.jumpcount < 0:
                neg = -1
            man.y -=(man.jumpcount ** 2) / 4 * neg
            man.jumpcount -= 1
 
        else:
            man.is_jump= False
            man.jumpcount = 10
 
    redrawwindow()
 
 
 
 
 
pygame.quit()
sys.exit()

I don’t use pygame, but there are certain things in your code that surprise me

This is probably the source of your problem. This code does nothing. It gets the draw attrbute from man and forgets it immediately. Maybe you want man.draw(game_window)?

In the redrawwindow you write

global walkcount

I can not find a global of that name, only an attribute of that name in the player class.

In the while loop more than every other line changes the man state:

That is called feature envy and points to missing methods in the object. It is not a fault, but in larger programs leads to hard to find bugs. Try to avoid that.

Thank you, it kind of works now but the back ground won’t show after I added code for it.

    def draw(self,game_window):
        if self.walkcount +1 >= 27:
            self.walkcount = 0
        
        if self.left:
            self.game_window.blit(walkleft,(self.x,self.y))
            self.walkcount += 1
        elif self.right:
            self.game_window.blit(walkright,(self.x,self.y))
            self.walkcount += 1
        else:
            self.game_window.blit(idle, (self.x,self.y))
            
        **self.game_window.blit(bg(self.x,self.y))**

can you also help me with that?

Again, I do not use pygame myself, so maybe I am way off here.

I think that should be:
self.game_window.blit(bg, (self.x,self.y))
Draw the background at self.x, self.y.

However, it means that the background will move with the protagonist. Is that what you want? Usually the background is static and the protagonist moves along it. It will work if the background is a single colour.

Also, because you blit the background after the protagonist, parts of the background that overlap with the protagonist will obscure the protagonist.