Skip to content

Instantly share code, notes, and snippets.

@TravisJoe
Created May 14, 2013 14:17
Show Gist options
  • Select an option

  • Save TravisJoe/5576258 to your computer and use it in GitHub Desktop.

Select an option

Save TravisJoe/5576258 to your computer and use it in GitHub Desktop.
Tkinter in python full screen example
from Tkinter import *
root = Tk()
w = Label(root, text="Hello, world!")
root.overrideredirect(True)
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight()))
root.focus_set() # <-- move focus to this widget
root.bind("<Escape>", lambda e: e.widget.quit())
w.pack()
root.mainloop()
@Yllelder

Copy link
Copy Markdown

In Python 3, Tkinter has changed to tkinter (in lowercase).

In this script, the escape key don't work :(

@XiaochuanWang

Copy link
Copy Markdown

simply change the quit function to this:
"lambda e: root.quit()"

@yogggoy

yogggoy commented May 8, 2018

Copy link
Copy Markdown
import Tkinter as tk

root = tk.Tk()
root.attributes('-fullscreen', True)
root.bind('<Escape>',lambda e: root.destroy())

src

@leosh64

leosh64 commented Jun 12, 2020

Copy link
Copy Markdown

The last version (by yoggoy) works well with python3. Just need to add root.mainloop() in the end to keep the app running.

@1anony1mous1

Copy link
Copy Markdown

hoi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment