#! /usr/bin/env python3 from tkinter import Tk, Canvas class Sudoku_menu(Tk): 'Mini application to demonstrate the failing of Control-2.' def __init__(self): # initialze Tk itself Tk.__init__(self) # Canvas self.c = Canvas(self, width=122, height=122, bg="white") self.c.grid(row=0) #define binding for Control- keys for i in range(0, 10): # control-1 .. control-9 self.c.bind( bytes("", 'utf-8'), lambda x=str(i): self.key_control_num(x)) self.c.focus_set() def key_control_num(self, event): 'Control-0 .. Control-9 has been pressed' print("key_control_num", event.keysym) if event.keysym == '0': self.quit() # initialize the application class app = Sudoku_menu() # start dispatcher app.mainloop()