为了账号安全,请及时绑定邮箱和手机立即绑定

我的 Python 线程启动但没有执行任何操作

我的 Python 线程启动但没有执行任何操作

繁花如伊 2023-05-23 16:25:52
我正在研究自定义基本功能以简化我的编码,例如 wait(seconds) 或 msg(...),现在我正在研究窗口设置和更新,它可以工作,但是当我把它放在线程,它不会做任何事情。我没有收到任何错误,所以我感到困惑和沮丧。我不需要你调试它或任何东西,我只需要帮助知道问题出在哪里以及为什么会出现问题。到目前为止,这是我的脚本(脚本在底部):#   Importsif True:    import pygame, math, random, time, sys, threading    from pygame.locals import *    pygame.init()#   Setupif True:    win_n = "New Project"    win_w = 800    win_h = 600    win_c = (0, 0, 0)#   Codeif True:    def wait(seconds):        time.sleep(seconds)    def wait_until(bool):        while not bool:            wait(0.001)#   Executeif True:    def e_ws():        mainClock = pygame.time.Clock()        pygame.display.set_caption(win_n)        monitor_size = [pygame.display.Info().current_w, pygame.display.Info().current_h]        screen = pygame.display.set_mode((win_w, win_h), pygame.RESIZABLE)        fullscreen = False        while True:            screen.fill(win_c)            for event in pygame.event.get():                if event.type == QUIT:                    pygame.quit()                    sys.exit()                if event.type == VIDEORESIZE:                    if not fullscreen:                        screen = pygame.display.set_mode((event.w, event.h), pygame.RESIZABLE)                if event.type == KEYDOWN:                        if fullscreen:                            screen = pygame.display.set_mode(monitor_size, pygame.FULLSCREEN)                        else:                            screen = pygame.display.set_mode((screen.get_width(), screen.get_height()),                                                             pygame.RESIZABLE)            pygame.display.update()            mainClock.tick(60)    t_ws = threading.Thread(target=e_ws)    t_ws.start()    print("done")
查看完整描述

1 回答

?
哈士奇WWW

TA贡献1799条经验 获得超6个赞

python yourscriptname.py从命令行运行脚本。



查看完整回答
反对 回复 2023-05-23
  • 1 回答
  • 0 关注
  • 136 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信