I have a created a new window using pygtk. I want the system to give it keyboard focus immediately. What I am doing works most of the time, but when a window already has focus my new window is ignored. Is there a way to force my window into keyboard focus? The code I am using to open the window is:
self.window = gtk.Window()
self.window.set_position(gtk.WIN_POS_CENTER)
self.window.connect("key-press-event", self.keypress)
self.window.connect("focus-out-event", self.cancel)
self.window.connect("destroy", self.cancel)
self.entry = gtk.Entry(200)
button = gtk.Button("go")
button.connect("clicked", self.command)
box = gtk.HBox()
box.add(self.entry)
box.add(button)
self.window.add(box)
self.window.set_keep_above(True)
self.window.show_all()
self.window.window.focus()
The window is not visible when the focus call is made. Try this: