Made a button class in python but cannot add to screen with pygame
Question: 
    import pygame, sys, time, random
    
    from pygame.locals import*
    
    pygame.init()
    
    class Button(object):
    
    def __init__(self, x, y):
        '''x_size, y_size,'''
        #self.name = name
        '''self.length = x_size'''
        '''self.height = y_size'''
        self.xpos = x
        self.ypos = y
        self.rect = (100,100)
        self.image = ('Images\Button_Test.png')
    
    def getRect(self):
        return self.rect
    
    
    def onClick():
        for event in pygame.event.get():
            if event.type == pygame.mouse.get_pressed():
                pos = pygame.mouse.get_pos()
                if self.collidepoint(pos):
                    return
    

the main class

    
    
    screen.blit(background,(0,0))
    screen.blit(testButton, testButton.getRect())
    pygame.display.flip()
    

> TypeError: argument 1 must be pygame.Surface, not Button

Can any one help me solve this error?


Answer: try this:

    
    
    screen.blit(testbutton.image,testbutton.get_rect())
    

you're currently telling it to `blit` an object and not the object's sprite

