[英]I don't know why this Python Programming code doesn't work
import pygame, sys
from pygame.locals import *
pygame.init()
screen=pygame.display.set_mode((640,360),0,32)
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.lock()
pygame.draw.rect(screen, (140,240,130), Rect((100,100),(130,170)))
screen.unlock()
pygame.display.update()
It's supposed to show a retangle in a 640x360 window, and it doesn't do that, and I don't know why it doesn't do that.它应该在 640x360 的窗口中显示一个 retangle,但它没有这样做,我不知道为什么它不这样做。 Please help me.请帮我。
It works like that:它是这样工作的:
You may be expected to behave differently?你可能会有不同的表现?
The following code works for me well.以下代码对我很有效。
#!/usr/bin/python
import pygame, sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640,360),0,32)
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.lock()
pygame.draw.rect(screen, (140,240,130), Rect((100,100),(130,170)))
screen.unlock()
pygame.display.update()
Though if you are facing any error, please share the error.但是,如果您遇到任何错误,请分享错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.