社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

TypeError:“module”对象在Python 3中不可调用

DeBeast591 • 5 年前 • 152 次点击  

pygame.rect() 但当我运行它时,它每次都会给我这个错误或类似的错误。

# Imports
import pygame

pygame.init()

# class
class Shape:
    def __init__(self, width, height, color):
        self.width = width
        self.height = height
        self.color = color
        self.SHAPE = pygame.rect(self, width, height, color)

# RunApp() function
def runApp(width, height):
    screen = pygame.display.set_mode((width, height))
    done = False

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

        pygame.display.flip()

测试.py( import main 将更改为 import pyseed.main

# PySeed Testing Zone
import main as pyseed

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

pyseed.runApp(400, 300)

谢谢你的帮助。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/54641
 
152 次点击  
文章 [ 1 ]  |  最新文章 5 年前
DeBeast591
Reply   •   1 楼
DeBeast591    5 年前

我的新代码:

主.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()

# PySeed Testing Zone
import main as pyseed

pyseed.setUp(400, 300)

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

pyseed.runApp()

谢谢你的帮助。