How to Create Full Screen Window in Tkinter?

How to Create Full Screen Window in Tkinter?

In the tkinter module for creating GUI applications in Python, you can create a full-screen window using the attributes method on a Tk window instance.

Here's a simple example of how to create a full-screen window using tkinter:

import tkinter as tk root = tk.Tk() # This will set the window to full screen root.attributes('-fullscreen', True) # If you want to have a way to exit the full-screen window, you can bind the 'Escape' key: def toggle_fullscreen(event=None): root.attributes('-fullscreen', not root.attributes('-fullscreen')) return "break" def end_fullscreen(event=None): root.attributes('-fullscreen', False) return "break" root.bind("<F11>", toggle_fullscreen) root.bind("<Escape>", end_fullscreen) root.mainloop() 

In the above example:

  • Setting the -fullscreen attribute to True with the attributes method makes the window go full screen.
  • The <F11> key binding toggles the window between full-screen and normal size.
  • The <Escape> key binding exits full-screen mode.

You can adjust the behavior as needed for your application.


More Tags

build-process testcafe android-sdk-tools nsdocumentdirectory kendo-dropdown google-api-js-client shorthand partitioning xml.etree pageload

More Programming Guides

Other Guides

More Programming Examples