Tk overrideredirect problem

Oguz Yarimtepe comp.ogz at
Tue Jul 8 07:10:28 CEST 2008


At my GUI application i am catching a key press action.  The code is
working if i don't enable the overrideredirect. When i comment out the
overriderect part i can see the  picture but i am not able to catch
the key presses. It seems like the GUI is stucked. But i want to have
windowless appereance that is just the picture itself. Also a working
application that will catch my key presses. So how can i fix it?

Here is the code part related with my question:

from Tkinter import *
from Xlib import *
import Image            #PIL
import ImageTk          #PIL

self.root = Tk()
self.root.bind('<Key>', self.action)

dsp = display.Display()
self.screen = dsp.screen().root

self.screen.grab_key(self.actionkey, X.AnyModifier, 1,X.GrabModeAsync,

# we tell the X server we want to catch keyPress event
self.screen.change_attributes(event_mask = X.KeyPressMask)

def action(self,event):
		#print event.keycode 		

		if event.keycode == self.actionkey:

def showImage(self,imageName="w_on_b_on.jpg"):

print imageName	

		im =

		xlocation = 440
		ylocation = 640

		width = im.size[0]+20
    		height = im.size[1]+20

    		newgeometry =

    		self.root.protocol('WM_DELETE_WINDOW', self.doExit)

    		# add 20 to account for border defined in create_image
    		self.canvas = Canvas(self.root, height=im.size[1]+20, width=im.size[0]+20)

    		photo = ImageTk.PhotoImage(im)
    		item = self.canvas.create_image(10,10,anchor=NW, image=photo)

		self.counter += 1


I didn't check the code below, the whole working one is here: I pasted it to give an idea.

Oğuz Yarımtepe

More information about the Python-list mailing list