How to bind Tkinter destroy() to a key in Debian?

前端 未结 3 2033
余生分开走
余生分开走 2020-12-22 05:08

The following code works correctly in MS Windows (the script exits when pressing q):

import Tkinter as tk

class App():
    def __init__(self):
         


        
3条回答
  •  滥情空心
    2020-12-22 06:13

    If a key binding doesn't work, it is likely that the window to which the binding is associated doesn't have the keyboard focus. In your situation with no window manager, your program probably doesn't have keyboard focus.

    You might try forcing it to have focus with root.focus_force(). This will sometimes give focus to a window even when the application as a whole isn't the foreground app. This is somewhat depending on the window manager, or lack thereof.

提交回复
热议问题