Daniel,<br><br>I played with your code last night at home.  I modified it so it actually loads pictures in the left and right Gtk.Image.  I found that when I tabbed through the controls in the window that the focus_in and focus_out methods were invoked.  However, when I tried to change the focus by clicking on either image nothing happened.  Before trying this I changed View Slides to eliminate the event box and the Activity still doesn't work.<br>
<br>I added code like this:<br><br>self.image1.set_events(Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.BUTTON_PRESS_MASK)<br><br>to your example but it had no effect.  You can tab into an Image but you can't make it take the focus by clicking on it.<br>
<br>This link suggests that the event box is necessary:<br><br><a href="http://stackoverflow.com/questions/14861503/catching-button-click-on-gtk-image-python-gtk3">http://stackoverflow.com/questions/14861503/catching-button-click-on-gtk-image-python-gtk3</a><br>
<br>I'm going to fool with this some more this weekend.<br><br>James Simmons<br><br><div class="gmail_quote">On Thu, Feb 28, 2013 at 10:20 AM, Daniel Narvaez <span dir="ltr"><<a href="mailto:dwnarvaez@gmail.com" target="_blank">dwnarvaez@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">GtkImage only works for me:<br>
<br>
from gi.repository import Gtk<br>
<br>
def image1_focus_in_cb(a, b):<br>
    print("focus in 1")<br>
<br>
def image1_focus_out_cb(a, b):<br>
    print("focus out 1")<br>
<br>
def image2_focus_in_cb(a, b):<br>
    print("focus in 2")<br>
<br>
def image2_focus_out_cb(a, b):<br>
    print("focus out 2")<br>
<br>
<br>
window = Gtk.Window()<br>
box = Gtk.HBox()<br>
<br>
image1 = Gtk.Image.new_from_file("")<br>
image1.set_can_focus(True)<br>
<br>
image1.connect("focus-in-event", image1_focus_in_cb)<br>
image1.connect("focus-out-event", image1_focus_out_cb)<br>
<br>
image2 = Gtk.Image.new_from_file("")<br>
image2.set_can_focus(True)<br>
<br>
image2.connect("focus-in-event", image2_focus_in_cb)<br>
image2.connect("focus-out-event", image2_focus_out_cb)<br>
<br>
box.pack_start(image1, False, False, 0)<br>
box.pack_start(image2, False, False, 0)<br>
<br>
window.add(box)<br>
window.show_all()<br>
<br>
Gtk.main()<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On 28 February 2013 17:06, Daniel Narvaez <<a href="mailto:dwnarvaez@gmail.com">dwnarvaez@gmail.com</a>> wrote:<br>
> Two things you could try:<br>
><br>
> - set_visible_window(True) the event box and also set_can_focus<br>
><br>
> - Remove the box and set_can_focus the image.<br>
><br>
><br>
> On Thursday, 28 February 2013, James Simmons wrote:<br>
>><br>
>> Gonzalo,<br>
>><br>
>> The problem with that it I want the arrow keys to page through the images<br>
>> only when the image has the focus.  There are other places in the Activity<br>
>> where I don't want to interfere with the arrow keys.  For instance, you can<br>
>> make annotations for a specific image.<br>
>><br>
>> I notice that GtkImage is a subclass of GtkWidget, so maybe that means<br>
>> that I don't need the event box anymore.  Maybe the image itself can accept<br>
>> the focus and receive the events.  The problem I have with that is that the<br>
>> old GTK made Image extend Widget also, and as I remember it you couldn't get<br>
>> events from an Image.  It was years ago.  Maybe I've been doing it wrong the<br>
>> whole time.<br>
>><br>
>> James Simmons<br>
>><br>
>><br>
>> On Wed, Feb 27, 2013 at 6:24 PM, Gonzalo Odiard <<a href="mailto:gonzalo@laptop.org">gonzalo@laptop.org</a>><br>
>> wrote:<br>
>>><br>
>>> Can you catch the key-press-event in the activity class?<br>
>>> I think other activities like Read or Terminal do this.<br>
>>><br>
>>> Gonzalo<br>
>>><br>
>>> On Wed, Feb 27, 2013 at 1:53 PM, James Simmons <<a href="mailto:nicestep@gmail.com">nicestep@gmail.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> Aneesh,<br>
>>>><br>
>>>> I'm trying to incorporate your GTK3 update to View Slides and release<br>
>>>> the result on ASLO.  The problem I'm still having is that I cannot page<br>
>>>> through the images using the keyboard as I used to.  What I did in the past<br>
>>>> was to nest the image control in an event box and make the event box able to<br>
>>>> accept the focus.  Then the user clicks on the image with the mouse to set<br>
>>>> the focus and at that point the event box receives key press events.<br>
>>>><br>
>>>> When you upgraded View Slides to use GTK3 you removed the code to make<br>
>>>> the event box focusable.  I have tried to replace the missing line of code<br>
>>>> with what seems to be the GTK3 equivalent but it isn't working.  I've done a<br>
>>>> lot of google searches trying to figure out the problem and I'm not getting<br>
>>>> anywhere.  I cannot release View Slides as it is.  It really needs to be<br>
>>>> able to navigate through the images with the keyboard to be usable.<br>
>>>><br>
>>>> I'm hoping you might have some thoughts or maybe an idea of how to do<br>
>>>> the keyboard paging a different way.<br>
>>>><br>
>>>> James Simmons<br>
>>>><br>
>>>><br>
>>>> On Mon, Feb 25, 2013 at 6:20 AM, Manuel Quiñones <<a href="mailto:manuq@laptop.org">manuq@laptop.org</a>><br>
>>>> wrote:<br>
>>>>><br>
>>>>> Hi James,<br>
>>>>><br>
>>>>> 2013/2/24 James Simmons <<a href="mailto:nicestep@gmail.com">nicestep@gmail.com</a>>:<br>
>>>>> > I was looking at the upgrade to GTK3 done for View Slides and it<br>
>>>>> > seems that<br>
>>>>> > it no longer responds to the keyboard.  What I had done previously to<br>
>>>>> > get it<br>
>>>>> > to do that was to put the image I was displaying in an event box.  I<br>
>>>>> > then<br>
>>>>> > made the event box accept the focus like this:<br>
>>>>> ><br>
>>>>> > self.eventbox.set_events(gtk.gdk.KEY_PRESS_MASK |<br>
>>>>> > gtk.gdk.BUTTON_PRESS_MASK)<br>
>>>>> > self.eventbox.set_flags(gtk.CAN_FOCUS)<br>
>>>>> ><br>
>>>>> > The Gtk3 port changed the code to this:<br>
>>>>> ><br>
>>>>> > self.eventbox.set_events(Gdk.EventMask.KEY_PRESS_MASK |<br>
>>>>> > Gdk.EventMask.BUTTON_PRESS_MASK)<br>
>>>>> ><br>
>>>>> > There was no code to make it accept the focus.  I tried adding this:<br>
>>>>> ><br>
>>>>> > self.eventbox.set_can_focus(True)<br>
>>>>> ><br>
>>>>> > This does not prevent the Activity from running, but it doesn't make<br>
>>>>> > the<br>
>>>>> > Event Box focusable either.<br>
>>>>><br>
>>>>> Have you tried self.eventbox.grab_focus() ?<br>
>>>>><br>
>>>>><br>
>>>>> <a href="http://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-grab-focus" target="_blank">http://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-grab-focus</a><br>
>>>>><br>
>>>>> --<br>
>>>>> .. manuq ..<br>
>>>><br>
>>>><br>
>>>><br>
>>>> _______________________________________________<br>
>>>> Sugar-devel mailing list<br>
>>>> <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
>>>> <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
>>>><br>
>>><br>
>><br>
><br>
><br>
> --<br>
> Daniel Narvaez<br>
><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Daniel Narvaez<br>
</font></span></blockquote></div><br>