The following code works correctly in MS Windows (the script exits when pressing q
):
import Tkinter as tk
class App():
def __init__(self):
self.root = tk.Tk()
self.root.geometry("{0}x{1}+0+0".format(
self.root.winfo_screenwidth(), self.root.winfo_screenheight())
)
self.root.overrideredirect(True)
tk.Label(text="some text here").grid()
self.root.bind('q', self.appexit)
self.root.mainloop()
def appexit(self, event):
self.root.destroy()
App()
I tried to run it in a "window manager-less" Debian environment (boot to console, run startx
, which launches the script via .xinitrc
(the only command there)).
The script starts as expected but pressing q
does not do anything (I was expecting X
to close and return to the text console). I later tried to add just in case self.root.focus()
before the mainloop()
but it did not help.
What could be the reason of this different behavior between the MS Windows and Debian environment?