Pygame TypeError: missing 1 required positional argument:

ddaniels

I am programming a game in Pygame. I kept running up on this error and I don't understand how to fix it.It runs the pauseMenu() init and prints what is in it so it can run it but after that I am stuck. Any help would be a appreciated.

Exact error:

Traceback (most recent call last):
  File "C:/Users/derek/Desktop/current workspace/Red_Fox/main.py", line 85, in <module>
    start()
  File "C:/Users/derek/Desktop/current workspace/Red_Fox/main.py", line 37, in start
60
    mainLoop()
  File "C:/Users/derek/Desktop/current workspace/Red_Fox/main.py", line 67, in mainLoop
    pauseMenu.pauseMenuFunct(DISPLAYSURF,(WINWIDTH,WINHEIGHT))
TypeError: pauseMenuFunct() missing 1 required positional argument: 'WINDIM'

The main is here and the file I am calling is under it.

import pygame,sys
from Player import *
from Block import *
from menu import *
from pauseMenu import *
from pygame.locals import *
goToMenu = True
def start():
    pygame.init()
    menuScreen = MenuScreen()
    pMenu = pauseMenu()

global  DISPLAYSURF,BRIGHTBLUE,FPSCLOCK, \
        FPS,player,objects, \
        WINHEIGHT,WINWIDTH,goToMenu, \
        objectsFP,WINDIM
FPS =  60 # frames per second to upate the screen
WINWIDTH = 800 # width of the program's window, in pixels
WINHEIGHT = 600 # height in pixels
WINDIM = WINWIDTH,WINHEIGHT
#WINWIDTH = 1920 # width of the program's window, in pixels
#WINHEIGHT = 1080 # height in pixels
FPSCLOCK = pygame.time.Clock()
BRIGHTBLUE = (  0, 170, 255)
DISPLAYSURF = pygame.display.set_mode((WINWIDTH, WINHEIGHT))
FPSCLOCK = pygame.time.Clock()
#player = Player(100,100)
objects = []
objectsFP = []
if goToMenu:
    goToMenu = False
    menuState = menuScreen.menuFunct(DISPLAYSURF,WINDIM,BRIGHTBLUE)

if menuState == 0:
    initGame()
    worldGen()
    mainLoop()
elif menuState == 1:
    print('Will have options here')


#global DISPLAYSURF,BRIGHTBLUE,FPSCLOCK,FPS

def worldGen():
    for i in range(int(WINHEIGHT/2),WINHEIGHT,10):
        for j in range(0,WINWIDTH,10):
            objects.append(Block(j,i))
            if(i == int(WINHEIGHT/2)):
                objectsFP.append(Block(j,i))
                print('happened dawg')
    for o in objectsFP:
        o.draw(DISPLAYSURF)
def initGame():
    print('in initGame()')
    objects.append(Player(100,100))

def mainLoop():
    while True:
        DISPLAYSURF.fill(BRIGHTBLUE)
        for event in pygame.event.get():
            if event.type == QUIT:
                quitCleanUp()
            elif event.type == KEYDOWN:
                objects[0].keyDownUpdate(event)
                if event.key == K_ESCAPE:
                    print(FPS)
                    pauseMenu.pauseMenuFunct(DISPLAYSURF,(WINWIDTH,WINHEIGHT))
            elif event.type == KEYUP:
                objects[0].keyUpUpdate(event)
        for i in objects:
            i.update()
            i.draw(DISPLAYSURF)
        #objectsFP = objects.copy()
        objects[0].objUpdate(objectsFP)
        #player.update()
        #player.draw(DISPLAYSURF)
        pygame.display.update()
        FPSCLOCK.tick(FPS)

def quitCleanUp():
    pygame.quit()
    sys.exit()

if __name__ == '__main__':
    start()

This is the other class that I am trying to call.

import pygame,time,sys
from pygame import *



class pauseMenu():

    goToMenu = False
    imageDict = {}
    textDict = {}
    rectDict = {}
    Clicked_Button = ''
    DarkGrey =      (134, 134, 134)
    volume = 10
    FPSCLOCK = pygame.time.Clock()


    def pauseMenuFunct(self,screen,WINDIM):
        print("made it here")
        def check_collisions(self,pos,list):
        # iterate dict, check for collisions in systems
        #     print('Made it to teh da function')
            for k,v in list.items():
                # print('Made into to the for loop')
                if v.collidepoint(pos):
                    # print(v)
                    # print("clicked button:", k)
                    self.Clicked_Button = k
                    # print(self.Clicked_Button)
                    return True,k

        WINWIDTH,WINHEIGHT = WINDIM
        # print('Made it to the function')
        # screen.fill(background)
        imageDict = {'buttons': pygame.image.load('Resources/Pics/PauseOptions.png')
        }

        imageDict['buttons']=pygame.transform.smoothscale(imageDict['buttons'],(int(WINWIDTH*.2),(int(WINHEIGHT*.1))))

        buttonX,buttonY= imageDict['buttons'].get_size()
        # print(buttonX , buttonY)
        textSize = int(buttonY/2)
        # print(textSize)
        self.font = pygame.font.Font('Resources/chunkfont.ttf', textSize)
        textOptions  = self.font.render("Options", 1, self.DarkGrey)
        textSave     = self.font.render("Save", 1, self.DarkGrey)
        textQuit     = self.font.render("Quit", 1, self.DarkGrey)
        textVolume   = self.font.render("Volume", 1, self.DarkGrey)
        textBackToGame = self.font.render('Return', 1, self.DarkGrey)
        VolumePopUp  = self.font.render(str(self.volume), 1, self.DarkGrey)
        textBackToMenu = self.font.render('Menu', 1 , self.DarkGrey)


        self.rectDict['Options'] =           screen.blit(imageDict['buttons'], (WINWIDTH/4,(WINHEIGHT/3)))
        self.rectDict['Save'] =              screen.blit(imageDict['buttons'], (WINWIDTH/2+60.5,WINHEIGHT/3))
        self.rectDict['Quit'] =              screen.blit(imageDict['buttons'], (WINWIDTH/4,(WINHEIGHT/2)))
        self.rectDict['Volume'] =            screen.blit(imageDict['buttons'], ((WINWIDTH/2+60.5),(WINHEIGHT/2)))
        self.rectDict['Return'] =            screen.blit(imageDict['buttons'], (WINWIDTH/4,(WINHEIGHT/1.5)))
        self.rectDict['Menu'] =              screen.blit(imageDict['buttons'], (WINWIDTH/2+60.5,WINHEIGHT/1.5))
        self.textDict['textOptions'] =       screen.blit(textOptions,(WINWIDTH/4 + (buttonX/4),(WINHEIGHT/3+textSize/2)))
        self.textDict['textQuit'] =          screen.blit(textQuit,(WINWIDTH/4 + (buttonX/4),(WINHEIGHT/2+textSize/2)))
        self.textDict['textSave'] =          screen.blit(textSave,(WINWIDTH/2+60.5 + (buttonX/3),(WINHEIGHT/3+textSize/2)))
        self.textDict['textVolume'] =        screen.blit(textVolume,(WINWIDTH/2+50.5 + (buttonX/4.5),(WINHEIGHT/2+textSize/2)))
        self.textDict['textBacktoGame']=     screen.blit(textBackToGame,(WINWIDTH/4+ (buttonX/4),(WINHEIGHT/1.5+textSize/2)))
        self.textDict['textMenu']=           screen.blit(textBackToMenu,(WINWIDTH/2+60.5+ (buttonX/4),(WINHEIGHT/1.5+textSize/2)))
        self.textDict['volumeNum']=          screen.blit(VolumePopUp,(WINWIDTH/2+55.5 + buttonX/1.25,(WINHEIGHT/2+textSize/2)))
        pygame.display.update()
        print('made it to the update')


        while True:
            self.FPSCLOCK.tick(60)
            for event in pygame.event.get():
                if event.type == QUIT:
                    sys.exit()
                elif event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        sys.exit()

                elif event.type == MOUSEBUTTONDOWN:
                    if event.button == 1:
                        if check_collisions(self,event.pos,self.rectDict):

                            # print('Button Clicked from Event Loop is: '+self.Clicked_Button)

                            if self.Clicked_Button == 'Quit':
                                sys.exit()
                            elif self.Clicked_Button == 'Save':
                                print('It will be saved later')
                            elif self.Clicked_Button == 'Volume' and self.volume>0:
                                self.volume -= 1
                                print(self.volume)

                                VolumePopUp  = self.font.render(str(self.volume), 1, self.DarkGrey)
                                screen.blit(imageDict['buttons'], ((WINWIDTH/2+60.5),(WINHEIGHT/2)))
                                screen.blit(VolumePopUp,(WINWIDTH/2+55.5 + buttonX/1.25,(WINHEIGHT/2+textSize/2)))

                                pygame.display.update(self.textDict['volumeNum'])


                            elif self.Clicked_Button == 'Return':
                                print('This will close the menu and you return you to the game.')
                            elif self.Clicked_Button == 'Options':
                                print('This will take you to an options screen')
                                #TODO Return values
                            elif self.Clicked_Button == 'Menu':
                                print('Will take you to main menu sooner or later')
                    elif event.button == 3:
                        if check_collisions(self,event.pos,self.rectDict):
                            if self.Clicked_Button == 'Volume' and self.volume<10:
                                self.volume += 1
                                print(self.volume)

                                VolumePopUp  = self.font.render(str(self.volume), 1, self.DarkGrey)
                                screen.blit(imageDict['buttons'], ((WINWIDTH/2+60.5),(WINHEIGHT/2)))
                                screen.blit(VolumePopUp,(WINWIDTH/2+55.5 + buttonX/1.25,(WINHEIGHT/2+textSize/2)))

                                pygame.display.update(self.textDict['volumeNum'])

                                #TODO Return volume values


    def __init__(self):
        print('PauseMenu _init_ ran')
Martijn Pieters

You are calling pauseMenu on the class itself:

pauseMenu.pauseMenuFunct(DISPLAYSURF,(WINWIDTH,WINHEIGHT))

This is an unbound function, so self will not be filled in for you.

You also create an instance somewhere:

def start():
    pygame.init()
    menuScreen = MenuScreen()
    pMenu = pauseMenu()

Perhaps you meant to call pMenu.pauseMenuFunct() instead?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Pygame - TypeError: Missing 1 required positional argument

From Java

TypeError: Missing 1 required positional argument: 'self'

From Dev

Pygame - can't draw image to screen: TypeError: draw() missing 1 required positional argument: 'surface'

From Dev

TypeError: func1() missing 1 required positional argument: 'self'

From Dev

missing 1 required positional argument

From Dev

TypeError: missing 1 required positional argument: 'self' but the class is instanciated

From Dev

python smtp TypeError: sendmail() missing 1 required positional argument: 'msg'

From Dev

TypeError: get_params() missing 1 required positional argument: 'self'

From Dev

TypeError: classify() missing 1 required positional argument: 'featureset'

From Dev

TypeError: insert() missing 1 required positional argument: 'string'

From Dev

python TypeError: __new__() missing 1 required positional argument: 'namespace'

From Dev

Pandas DataFrame TypeError: quantile() missing 1 required positional argument: 'quantile'?

From Dev

TypeError: lemmatize() missing 1 required positional argument: 'word

From Dev

TypeError: __call__() missing 1 required positional argument: 'inputs'

From Dev

python decorator TypeError missing 1 required positional argument

From Dev

TypeError: <lambda>() missing 1 required positional argument: 'w'

From Dev

TypeError: on_message() missing 1 required positional argument: 'message'

From Dev

TypeError: delete() missing 1 required positional argument: 'indexPosition'

From Dev

tensorflow TypeError: ParseFromString() missing 1 required positional argument: 'serialized'

From Dev

TypeError: x missing 1 required positional argument: y

From Dev

TypeError: player_attack() missing 1 required positional argument: 'self'

From Dev

TypeError: cone() missing 1 required positional argument: 'height'

From Dev

TypeError on Python. Missing1 required positional argument

From Dev

TypeError: __init__() missing 1 required positional argument: 'id'

From Dev

TypeError: str() missing 1 required positional argument: 'self'

From Dev

TypeError: insert() missing 1 required positional argument: 'string'

From Dev

Python TypeError: set() missing 1 required positional argument: 'value'

From Dev

TypeError: askopenfilename() missing 1 required positional argument: 'root' In [ ]:

From Dev

TypeError: grid_configure() missing 1 required positional argument: 'self'

Related Related

  1. 1

    Pygame - TypeError: Missing 1 required positional argument

  2. 2

    TypeError: Missing 1 required positional argument: 'self'

  3. 3

    Pygame - can't draw image to screen: TypeError: draw() missing 1 required positional argument: 'surface'

  4. 4

    TypeError: func1() missing 1 required positional argument: 'self'

  5. 5

    missing 1 required positional argument

  6. 6

    TypeError: missing 1 required positional argument: 'self' but the class is instanciated

  7. 7

    python smtp TypeError: sendmail() missing 1 required positional argument: 'msg'

  8. 8

    TypeError: get_params() missing 1 required positional argument: 'self'

  9. 9

    TypeError: classify() missing 1 required positional argument: 'featureset'

  10. 10

    TypeError: insert() missing 1 required positional argument: 'string'

  11. 11

    python TypeError: __new__() missing 1 required positional argument: 'namespace'

  12. 12

    Pandas DataFrame TypeError: quantile() missing 1 required positional argument: 'quantile'?

  13. 13

    TypeError: lemmatize() missing 1 required positional argument: 'word

  14. 14

    TypeError: __call__() missing 1 required positional argument: 'inputs'

  15. 15

    python decorator TypeError missing 1 required positional argument

  16. 16

    TypeError: <lambda>() missing 1 required positional argument: 'w'

  17. 17

    TypeError: on_message() missing 1 required positional argument: 'message'

  18. 18

    TypeError: delete() missing 1 required positional argument: 'indexPosition'

  19. 19

    tensorflow TypeError: ParseFromString() missing 1 required positional argument: 'serialized'

  20. 20

    TypeError: x missing 1 required positional argument: y

  21. 21

    TypeError: player_attack() missing 1 required positional argument: 'self'

  22. 22

    TypeError: cone() missing 1 required positional argument: 'height'

  23. 23

    TypeError on Python. Missing1 required positional argument

  24. 24

    TypeError: __init__() missing 1 required positional argument: 'id'

  25. 25

    TypeError: str() missing 1 required positional argument: 'self'

  26. 26

    TypeError: insert() missing 1 required positional argument: 'string'

  27. 27

    Python TypeError: set() missing 1 required positional argument: 'value'

  28. 28

    TypeError: askopenfilename() missing 1 required positional argument: 'root' In [ ]:

  29. 29

    TypeError: grid_configure() missing 1 required positional argument: 'self'

HotTag

Archive