Код: Выделить всё
from tkinter import *
from tkinter import ttk
import keyboard
root = Tk()
def p():
print('hello')
BUT_Quitter = ttk.Button ( root , text = "Quitter" , command = root.destroy )
BUT_Quitter.pack ( )
BUT_display = ttk.Button ( root , text = "Hello" , command = p )
BUT_display.pack ( )
def key_press(event):
key = event.char
if key=='q':
BUT_display.invoke()
root.bind('', key_press)
root.mainloop ( )
Подробнее здесь: https://stackoverflow.com/questions/793 ... er-buttons
Мобильная версия