How can I make a Tkinter window take up all my display screen area?

Recommended Answers

All 6 Replies

Hi!

root = Tk()

w, h = root.winfo_screenwidth(), root.winfo_screenheight()
# use the next line if you also want to get rid of the titlebar
root.overrideredirect(1)
root.geometry("%dx%d+0+0" % (w, h))

Regards, mawe

Thanks! The question and answer were both helpful.

Jeff

Thanks mawe, that works well.

Just a question, if get rid of the titlebar, how can I exit the program?

Thanks mawe, that works well.

Just a question, if get rid of the titlebar, how can I exit the program?

You need to at Exit to your menu or add an exit button.

To exit, you can also use a key-binding. Look:

import Tkinter as tk

def exit(event):
    root.quit()

root = tk.Tk()
tk.Label(text="Press <ESC> to exit").pack()
root.bind("<Escape>", exit)
root.mainloop()

Just press the Esc-Key and ... that's it ;)

To exit, you can also use a key-binding. Look:

import Tkinter as tk
 
def exit(event):
    root.quit()
 
root = tk.Tk()
tk.Label(text="Press <ESC> to exit").pack()
root.bind("<Escape>", exit)
root.mainloop()

Just press the Esc-Key and ... that's it ;)

Thanks, that works well.

Just a question, when do you use root.quit() and root.destroy()? I have seen them both.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.