【发布时间】:2012-05-05 22:12:42
【问题描述】:
打开pygame.display 窗口,我调用pygame.display.quit() 以销毁窗口。
因为需要再次打开窗口,所以调用了pygame.display.init()和pygame.display.set_mode(),但是调用这两个函数之后,什么都没有发生。
谁能指出这个问题的根源?
【问题讨论】:
打开pygame.display 窗口,我调用pygame.display.quit() 以销毁窗口。
因为需要再次打开窗口,所以调用了pygame.display.init()和pygame.display.set_mode(),但是调用这两个函数之后,什么都没有发生。
谁能指出这个问题的根源?
【问题讨论】:
这里是带有 gui 模块的示例代码... 每当您调用 screen_off() 时,显示就会退出。每当您想恢复显示时,请输入您之前使用的所有内容以将其打开。
如果你愿意,可以使用pygame.display.quit(),而不是在screen_off() 函数中。我建议将你用来打开显示器的所有代码放入一个函数中,这样你就不必在它被杀死后再次输入它来打开它。
from pygame import *
from pygame.locals import *
import pygame, pygame.locals
from easygui import *
def screen_off():
pygame.display.quit()
pygame.init()
canvas = pygame.display.set_mode((400,400),0,32)
red = (255,0,0)
canvas.fill(red)
pygame.display.update()
screen_off() #display is now OFF...
choice = ['Yes', 'No']
cc = buttonbox('Continue?', "Options", choice)
if cc == "Yes":
#if you don't want to type these arguments below again to turn on the display then
#put them into a function and call it
pygame.init()
canvas = pygame.display.set_mode((400,400),0,32)
purple = (204,0,204)
canvas.fill(purple)
pygame.display.update()
#display is now ON...
【讨论】:
应该是:
pygame.init()
所以我假设:
pygame.quit()
作用相同
【讨论】:
你试过只打电话给pygame.quit() 或pygame.init()吗?我不相信有pygame.display.quit()。
【讨论】:
pygame.display.quit,而且这并不能回答OP的问题。