How do I display a tkinter application in fullscreen on macOS?

前端 未结 1 1097
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 07:24

I am just learning python, and I am trying to make a window go full screen, which I have achieved, but I am now wanting to get rid of the title bar across the top. It curren

1条回答
  •  再見小時候
    2021-01-14 08:06

    I believe what you want to do is use

    root.wm_attributes('-fullscreen','true')

    Try this instead. It should do the trick.

    from tkinter import *
    root = Tk()
    
    root.wm_attributes('-fullscreen','true')
    
    def quitApp():
        root.destroy()
    
    button = Button(text = 'QUIT', command = quitApp).pack()
    
    root.mainloop()
    

    If this does not work because of the MacOS then take a look at this link This useful page has sever examples of how to manage mack windows in tkinter. And I believe what you may need to get borderless fullscreen.

    This bit of code might be what you need:

    root.tk.call("::tk::unsupported::MacWindowStyle", "style", root._w, "plain", "none")
    

    Note: If you do use this option then you will need to remove root.wm_attributes('-fullscreen','true') from your code or just comment it out.

    Update:

    There is also another bit of code for tkinter 8.5+.

    If you are using python with tkinter 8.5 or newer:

    root.wm_attributes('-fullscreen', 1)
    

    0 讨论(0)
提交回复
热议问题