当前位置:网站首页>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 .
边栏推荐
- Eclipse project recompile, clear cache
- D2L installation
- 611. 有效三角形的个数
- Binary search (half search)
- I implement queue with C I
- SOC_ SD_ DATA_ FSM
- Simple operation of running water lamp (keil5)
- Three body goal management notes
- Reading literature sorting 20220104
- Implementation of one-dimensional convolutional neural network CNN based on FPGA (VIII) implementation of activation layer
猜你喜欢
Do you choose pandas or SQL for the top 1 of data analysis in your mind?
CADD课程学习(6)-- 获得已有的虚拟化合物库(Drugbank、ZINC)
【idea】Could not autowire. No beans of xxx type found
Matrix and TMB package version issues in R
Rough notes of C language (1)
1290_ Implementation analysis of prvtaskistasksuspended() interface in FreeRTOS
Don't confuse the use difference between series / and / *
Chapter 2: try to implement a simple bean container
大学生活的自我总结-大一
【Node】nvm 版本管理工具
随机推荐
QT small case "addition calculator"
Do you choose pandas or SQL for the top 1 of data analysis in your mind?
Batch convert txt to excel format
Altimeter data knowledge point 2
HDU1231 最大连续子序列(分治or动规or双指针)
[software testing] 03 -- overview of software testing
[software testing] 06 -- basic process of software testing
Concurrent programming - how to interrupt / stop a running thread?
Unforgettable summary of 2021
Basic series of SHEL script (II) syntax + operation + judgment
SOC_ SD_ DATA_ FSM
Cookie operation
C#学习笔记
SD_ CMD_ SEND_ SHIFT_ REGISTER
Anaconda navigator click open no response, can not start error prompt attributeerror: 'STR' object has no attribute 'get‘
[OBS] x264 Code: "buffer_size“
611. 有效三角形的个数
[software testing] 05 -- principles of software testing
Import CV2 prompt importerror: libgl so. 1: Cannot open shared object file: no such file or directory
借助 Navicat for MySQL 软件 把 不同或者相同数据库链接中的某数据库表数据 复制到 另一个数据库表中