2012-05-05 2 views
3

창이 열린 pygame.display 창이 열려 있으면 창을 파괴하기 위해 pygame.display.quit()을 호출합니다.
다시 창을 열어야하기 때문에 pygame.display.init()pygame.display.set_mode()을 호출하지만이 두 함수를 호출 한 후에는 아무 것도 발생하지 않습니다.
누구든지이 문제의 근원을 알려줄 수 있습니까?파이 게임 디스플레이 모듈 초기화 및 종료

답변

-1

pygame.quit() 또는 pygame.init()으로 전화를 걸어 보았습니까? 나는 pygame.display.quit()이 있다고 생각하지 않습니다.

+0

작동 :

pygame.init() 

그래서 나는 그 asssume. 거기에'pygame.display.quit'이 있는데, OP의 질문에 답을주지 않습니다. – bcdan

1

다음은 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... 
0

이 있어야한다 :

pygame.quit() 

이 대답은 잘못 같은