def on_release(self, event, function, *args): if event.type == pygame.MOUSEBUTTONUP: if event.button == 1: if self.rect.R.collidepoint(event.pos): function(*args) if args else function()