Pygame init and quit display module

Opening the window pygame.display, I call pygame.display.quit()to destroy the window.
Since I need to open the window again, I call pygame.display.init()and pygame.display.set_mode(), but after calling these two functions, nothing happens.
Can someone point me to the root of this problem?

+3
source share
3 answers

Here is a sample code with the gui module ... Whenever you call screen_off(), the display closes. Whenever you want the display to return, enter whatever you used to turn it on.

, 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...
+1

:

pygame.init()

, :

pygame.quit() 

0

Have you tried calling only pygame.quit()or pygame.init()? I do not believe that there is pygame.display.quit().

-1
source