import tkinter as tk
from tkinter import ttk
def close_escape(event=None):
print('pressed')
window.overrideredirect(False)
window.destroy()
# window
window = tk.Tk()
window.title('window')
# security event
window.bind('<Escape>', close_escape)
# window.bind('<Escape>', lambda event: window.quit())
# window.bind('<Escape>', lambda event: window.destroy())
# window.bind('<Escape>', lambda event: print('esc'))
window.after(3000, window.destroy)
# title bar
window.overrideredirect(True)
# run
window.mainloop()
python 3.12, MacOS 14.1.2, tkinter 8.6
None of the security event with bind work. I find someone said on Mac and linux may remove events sanding from system to the program.
Are there any way of removing the title bar and still being able to close the app?
I know if I put title as nothing it kind of gives me the same result though.
Saw someone use ('-type', 'splash') to get a splash screen. Not the case and not showing any effect here...
Also, not looking for fullscreen solution.
You need to give the window the keyboard focus so that it gets keyboard events.
...
# title bar
window.overrideredirect(True)
window.after_idle(window.focus_force)
...