Hi,

I have  a problem about using overrideredirect(1) and binding events
to the keys.

At my application i am creating  root and binding an action to a ke press as:

self.root = Tk()
#self.root.overrideredirect(1)
self.root.focus()
#self.frame.pack()
self.root.bind('<Key>', self.action)
self.root.title("Status")

The action method is as:

def action(self,event):
                #print event.keycode            
                if event.keycode == self.actionkey:
                        self.showImage()

So when i press a key i want to a different image on the screen:

def showImage(self):    
               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.canvas.update()
                self.root.mainloop()

if i comment out the self.root.overrideredirect(1) part, i can see the
winowless gui but i am not able to catch the keypress events this
time. The application is working nice without the
self.root.overrideredirect(1) part. But i want ti have windowless
application, how can i fix it?

I didn't put the whole code above, just the related part. As you can
guess, i have a class definition.

-- 
Oğuz Yarımtepe
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to