类型错误:';模块';对象在Python 3中不可调用

类型错误:';模块';对象在Python 3中不可调用,python,pygame,python-3.7,Python,Pygame,Python 3.7,我正在使用PyGame用Python 3.7制作我自己的“游戏引擎”。我想创建一个使用pygame.rect()函数的类,但当我运行它时,每次都会出现此错误或类似错误 main.py(./pyseed/) testing.py(import main将更改为import pyseed.main) 谢谢您的帮助。我的新代码: main.py # Made by DeBeast591 # Enjoy! # Imports import pygame # Getting PyGame ready.

我正在使用PyGame用Python 3.7制作我自己的“游戏引擎”。我想创建一个使用
pygame.rect()
函数的类,但当我运行它时,每次都会出现此错误或类似错误

main.py(./pyseed/)

testing.py(
import main
将更改为
import pyseed.main

谢谢您的帮助。

我的新代码:

main.py

# Made by DeBeast591
# Enjoy!

# Imports
import pygame

# Getting PyGame ready...
pygame.init()
print("Welcome to PySeed!\nMade By DeBeast591\nEnjoy!")

def setUp(width, height):
    global screen
    screen = pygame.display.set_mode((width, height))

# class
class Shape:
    def __init__(self, x, y, width, height, color):
        global screen
        self.width = width
        self.height = height
        self.x = x
        self.y = y
        self.color = color
        self.SHAPE = pygame.draw.rect(screen, self.color,pygame.Rect(self.x, self.y, self.width, self.height))

# RunApp() function
def runApp():
    global screen
    done = False

    while not done:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                done = True

        pygame.display.flip()
测试.py

# PySeed Testing Zone
import main as pyseed

pyseed.setUp(400, 300)

myShape = pyseed.Shape(30, 30, 90, 90, (0, 100, 255))

pyseed.runApp()

谢谢你的帮助。

为什么你认为
pygame.rect
是一个函数?我想你的意思是
pygame.rect()
(注意'R'不是'R'),它是一个
初始化器调用,所以不是真正的函数调用,但就所有意图和目的而言,它都是。@Kingsley,我对程序做了一些更改,发现我必须使用“pygame.draw.rect()”。谢谢你的帮助!
# Made by DeBeast591
# Enjoy!

# Imports
import pygame

# Getting PyGame ready...
pygame.init()
print("Welcome to PySeed!\nMade By DeBeast591\nEnjoy!")

def setUp(width, height):
    global screen
    screen = pygame.display.set_mode((width, height))

# class
class Shape:
    def __init__(self, x, y, width, height, color):
        global screen
        self.width = width
        self.height = height
        self.x = x
        self.y = y
        self.color = color
        self.SHAPE = pygame.draw.rect(screen, self.color,pygame.Rect(self.x, self.y, self.width, self.height))

# RunApp() function
def runApp():
    global screen
    done = False

    while not done:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                done = True

        pygame.display.flip()
# PySeed Testing Zone
import main as pyseed

pyseed.setUp(400, 300)

myShape = pyseed.Shape(30, 30, 90, 90, (0, 100, 255))

pyseed.runApp()