当前位置:网站首页>Exit of pyGame, idle and pycharm
Exit of pyGame, idle and pycharm
2022-07-05 07:28:00 【work-harder】
background :
win8.1, python3.9.7, idle(3.9.7), pycharm(2021.3.1)
Purpose :
pygame After operation , Click on “x" after , The interface closes when exiting , There is no need for the system to automatically prompt whether to close the program
The phenomenon :
1. The method given in a lecture is as follows ( The editor is pycharm), You can really see the program exit smoothly :
if event.type == pygame.QUIT:
print("Game Over") # Test statement
exit()
2. I use it python Self contained idle, Results run pygame After the app , The running window appears normally ( Code name A). Click on "x" after , There is no exit window (A), There's no hint . But according to the added test statements (print sentence ), Yes, I did . It turned out , There is a warning pop-up that requires the user to confirm whether to exit “ hide ” Behind the running window .
3. Change the above exit code to the following ,idle and pycharm Can exit normally , No additional confirmation is required .
if event.type == pygame.QUIT: # The front has import pygame
print("Game Over") # Test statement
pygame.quit() # Don't add this line ,idle Middle window cannot exit
sys.exit() # The front has import sys; direct exit(), Can't quit .
边栏推荐
- Simple operation of nixie tube (keil5)
- Use go language to read TXT file and write it into Excel
- 【idea】Could not autowire. No beans of xxx type found
- [node] NVM version management tool
- Miracast技术详解(一):Wi-Fi Display
- [tf1] save and load parameters
- CADD课程学习(5)-- 构建靶点已知的化合结构(ChemDraw)
- Rough notes of C language (1)
- C learning notes
- [framework] multi learner
猜你喜欢
Hdu1232 unimpeded project (and collection)
Daily Practice:Codeforces Round #794 (Div. 2)(A~D)
M2DGR 多源多场景 地面机器人SLAM数据集
SD_ CMD_ SEND_ SHIFT_ REGISTER
借助 Navicat for MySQL 软件 把 不同或者相同数据库链接中的某数据库表数据 复制到 另一个数据库表中
Import CV2 prompt importerror: libgl so. 1: Cannot open shared object file: no such file or directory
C learning notes
Jenkins reported an error. Illegal character: '\ufeff'. Class, interface or enum are required
Don't confuse the use difference between series / and / *
Shadowless cloud desktop - online computer
随机推荐
Basic series of SHEL script (I) variables
Set theory of Discrete Mathematics (I)
2022.06.27_ One question per day
Using GEE plug-in in QGIS
剑指 Offer 56 数组中数字出现的次数(异或)
Altimeter data knowledge point 2
Pytorch has been installed in anaconda, and pycharm normally runs code, but vs code displays no module named 'torch‘
NPM and package common commands
氢氧化钠是什么?
[vscode] prohibit the pylance plug-in from automatically adding import
目标检测系列——Faster R-CNN原理详解
D2L installation
[framework] multi learner
How to modify the file path of Jupiter notebook under miniconda
2022 PMP project management examination agile knowledge points (7)
With the help of Navicat for MySQL software, the data of a database table in different or the same database link is copied to another database table
Application of MATLAB in Linear Algebra (4): similar matrix and quadratic form
Target detection series - detailed explanation of the principle of fast r-cnn
[tf1] save and load parameters
Unity ugui how to match and transform coordinates between different UI panels or uis