focus problem with full-screen in Tkinter

Michele Simionato mis6 at pitt.edu
Mon Jul 14 14:56:23 EDT 2003


I have a problem with full screen windows in Tkinter.
Here is a minimal script showing the problem:

from Tkinter import *
root=Tk()
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.geometry("%dx%d+0+0" % (w, h))
#root.overrideredirect(1)
root.focus()
root.bind("<q>",lambda e: root.destroy())
root.bind("<1>",lambda e: root.destroy())
root.mainloop()

Here everything works, and if I press "q" the window is destroyed.
However, if I uncomment the line with "overrideredirect" and I
really go full screen, Tkinter does not recognize the keybindings
and I cannot close the window with "q". Fortunately, the mouse
is recognized and I can close the window with a click.

I guess the problem is with the focus, how should I modify root.focus()
to ensure that the keybindings are recognized?

TIA,

           Michele

P.S. I am using Python 2.2 on Red Hat 7.3




More information about the Python-list mailing list