我试图在python3.8中创建一个应用程序,它显示在系统托盘中,允许您左键单击以打开gui,右键单击以显示选项。我可以使用关闭gui并重新打开它,但它确实显示一个错误pygame.error:display Surface quit。我想确保脚本继续运行,并且只在用户想要退出时停止
from infi.systray import SysTrayIcon
import pygame
def pyg_lanucher():
pygame.init()
window = pygame.display.set_mode((500, 500))
run = True
while run:
# event loop
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
break
#sys.exit()
# clear the display
window.fill(0)
# draw the scene
pygame.draw.circle(window, (255, 0, 0), (250, 250), 100)
# update the display
pygame.display.flip()
#pygame.display.update()
#print(fpsClock.tick(FPS))
def open_gui(systray):
print('opening gui')
pyg_lanucher()
def say_hello(systray):
print ("Hello, World!")
menu_options1 = (("Open GUI", None, open_gui),)
menu_options2 = (("Say Hello", None, say_hello),)
systray = SysTrayIcon("icon.ico", "Example tray icon", menu_options1+menu_options2)
systray.start()
目前没有回答
相关问题 更多 >
编程相关推荐