有一個pygame.display
窗口打開,我呼籲它pygame.display.quit()
爲了銷燬窗口。
因爲我需要再次打開窗口,我打電話pygame.display.init()
和pygame.display.set_mode()
,但是在調用這兩個函數之後,什麼都不會發生。
任何人都可以指出這個問題的根源嗎?pygame的顯示模塊初始化和退出
3
A
回答
-1
你有沒有打過電話只是pygame.quit()
或pygame.init()
?我不相信有一個pygame.display.quit()
。
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.init()
,所以我asssume是:
pygame.quit()
的工作原理相同
相關問題
- 1. Pygame midi模塊初始化失敗
- 2. 意外退出初始化
- 3. 的JavaScript模塊創建和初始化
- 4. 內核模塊初始化和退出函數調用順序錯誤
- 5. 初始化Ruby模塊
- 6. Python模塊初始化
- 7. Powershell模塊初始化
- 8. 初始化模塊python
- 9. Javascript模塊模式和子模塊初始化模式
- 10. 使用pygames碰撞模塊沒有初始化顯示
- 11. 加載模塊和初始化模塊之間的區別?
- 12. 即使pygame的初始化「未初始化視頻系統」被拋出
- 13. 初始化塊
- 14. Ruby類初始化覆蓋模塊初始化
- 15. Js模塊模式多個初始化
- 16. 如何以模塊模式初始化
- 17. Git的子模塊沒有初始化
- 18. PHP無法初始化zorba_api的模塊
- 19. Node.js模塊的異步初始化
- 20. Python的鉤子模塊初始化
- 21. 視頻系統未初始化pygame的
- 22. Java初始化塊
- 23. JAVA初始化塊
- 24. Prawnto初始化塊
- 25. 揭示模塊模式函數初始化樣式
- 26. Spring JMS獨立模塊初始化
- 27. 使用ES6模塊執行初始化
- 28. RequireJS未正確初始化模塊
- 29. zf2模塊(DoctrineModule)無法初始化
- 30. 如何初始化MVC模塊?
這個答案是錯的。有一個'pygame.display.quit',加上這個不能回答OP的問題。 – bcdan