Hi,

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.overrideredirect(1)
self.root.title("Status")
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,
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:
                        
                        self.showImage()


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

print imageName 

                im = Image.open(imageName)

                xlocation = 440
                ylocation = 640

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

                newgeometry =
str(width)+"x"+str(height)+"+"+str(xlocation)+"+"+str(ylocation)

                self.root.geometry(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)
                self.canvas.pack(side=LEFT,fill=BOTH,expand=1)

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

                self.counter += 1
                
                #self.canvas.update()

                mainloop()

I didn't check the code below, the whole working one is here:
http://rafb.net/p/SvqqjH64.html I pasted it to give an idea.

-- 
Oğuz Yarımtepe
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to