Tkinter'da tuşa basıldığında işlem yapma

Arkadaşlar ben tkinter ile işletim sistemine benzer bir şey yapıyorum, keyboard modülünü kullanıyorum.
İstediğim şey şu;

esc tuşuna bastığımda pencereyi kapatması.

import keyboard
import pyautogui
import tkinter
from tkinter import*
from PIL.ImageTk import PhotoImage

root = Tk()
root.minsize("1920","1080")
root.overrideredirect(1)
simge1 = PhotoImage(file="5.png")

def menü():
    menü = Frame(root, bg="#303030")
    menü.place(x=0, y=510, height=520, width=350)
    gizle = Button(menü, text="Gizle", bg="#191919", fg="white",activeforeground="#F6B737", activebackground="#191919", highlightbackground="#F6B737", command=menü.destroy)
    gizle.place(x=233, y=480, height=40, width=60)
    çıkış = Button(menü, text="Kapat", bg="#191919", fg="white",activeforeground="#F6B737", activebackground="#191919", highlightbackground="#F6B737", command=exit)
    çıkış.place(x=291, y=480, height=40, width=60)

#altçubuk
görev_cubuğu = Frame(root,bg="#191919")
görev_cubuğu.place(x=0, y=1030, height=50, width=1920)

menu = Button(görev_cubuğu, text="F", bg="#191919", fg="white", activebackground="#191919",image=simge1, highlightbackground="#191919", command=menü)
menu.place(x=0, y=0,height=50,width=60)

root.mainloop()

hocam tam ekran çalışıyosun sanırım bu işine yarayabilir:

import tkinter as tk

root = tk.Tk()
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.overrideredirect(1)
root.geometry("%dx%d+0+0" % (w, h))
root.bind('<Escape>',exit) # Tam ekranda çalışmıyorsan sadece bunu kullanman yeterli üst kısım tam ekran oluşturma
root.mainloop()

Çalıştı teşekkürler. Peki aynı olayın ‘Frame()’ için olanı var mı?

root.bind('<Escape>',exit) şunu yazman yeterli bi sayfayı komple kapatıyor herhangi bir yerde olmasına gerek yok

teşekkürer…

1 Beğeni