python turtle窗口全屏切换与隐藏鼠标指针

python turtle窗口全屏切换与隐藏鼠标指针

turtle模块基于tkinter模块开发,所以只要查阅tkinter模块的功能即可! 以下程序运行后,单击鼠标右键则窗口会在全屏与非全屏之间切换,以下是代码:

import turtle

def alt_screen(x,y):
    screen.status = not screen.status
    screen._root.attributes('-fullscreen', screen.status)
    
screen = turtle.Screen()
screen.status = False
screen._root.config(cursor="mouse")          # 修改为None则是隐藏鼠标指针
screen._root.attributes('-fullscreen', True)
screen.onclick(alt_screen,3)
screen.mainloop()

李兴球

李兴球的博客是Python创意编程原创博客