From: Tim L. <ti...@cs...> - 2005-04-13 09:32:56
|
Hi all, I'm developing an app where i'd like the user to be able to navigate using the up/down/left/right keys. Currently the mpl event handlers just return None for these, but I figured it'd be easy enough to add the code myself. in lib/matplotlib/backends/backend_gtk.py I added the following diff, which adds in some new code -> string mappings and also notifies me when a key press or key release is made (for debugging). 109,112d108 < 65361 : 'left', < 65362 : 'up', < 65363 : 'right', < 65364 : 'down', 176c172 < --- > 184d179 < print "hit", key 189d183 < print "release", key This all works fine except that the down key doesn't register as released. After registering the down key press, no other key events register until you hit the up key, at which point the key release triggers for the up. If i hit the following sequence: [up, left, right, down, <any sequence not including up or down>, up, up] I get the following events registering. hit up release up hit left release left hit right release right hit down <== we never get the matching "release down" or anything else release up <== until we hit the up key and get this release event for it hit up release up I really don't know a lot about Gtk or the matplotlib internals so I couldn't trace this bug deeper into the libraries. Can anyone shed some light on what's going on? If we can get the arrow keys working is there a chance of getting them into the standard distribution (assuming we had all backends working)? Cheers, Tim Leslie |
From: John H. <jdh...@ac...> - 2005-04-13 14:23:44
|
>>>>> "Tim" == Tim Leslie <ti...@cs...> writes: Tim> This all works fine except that the down key doesn't register Tim> as released. After registering the down key press, no other Tim> key events register until you hit the up key, at which point Tim> the key release triggers for the up. It works fine for me -- what is your pygtk version and OS? I'm using pygtk 2.2.0 on linux. You might put some debug print statements to print event.keyval in _get_key to see if an event is being triggered at the gtk level. Could it be a bad keyboard??? Tim> I really don't know a lot about Gtk or the matplotlib Tim> internals so I couldn't trace this bug deeper into the Tim> libraries. Can anyone shed some light on what's going on? If Tim> we can get the arrow keys working is there a chance of Tim> getting them into the standard distribution (assuming we had Tim> all backends working)? Absolutely. It might be nice to enable some standard keyboard navigation too. JDH |
From: Tim L. <ti...@cs...> - 2005-04-13 14:33:53
|
On Wed, 13 Apr 2005, John Hunter <jdh...@ac...> wrote... > >>>>> "Tim" == Tim Leslie <ti...@cs...> writes: > > Tim> This all works fine except that the down key doesn't register > Tim> as released. After registering the down key press, no other > Tim> key events register until you hit the up key, at which point > Tim> the key release triggers for the up. > > It works fine for me -- what is your pygtk version and OS? > I'm using pygtk 2.2.0 on linux. AFAICT pygtk 2.0, this is running on ubuntu unstable. > > You might put some debug print statements to print event.keyval in > _get_key to see if an event is being triggered at the gtk level. OK, I'll have a play with that. > > Could it be a bad keyboard??? Yep :) Well, maybe. The down key works in every other app I use, but I've had problems with this keyboard in strange ways before, so I wouldn't put it past it. I'll try it out on another machine when I get a chance and see how it goes. It's a laptop, so I can't really change the keyboard. (hmm, maybe a usb external one, if I had one) > > Tim> I really don't know a lot about Gtk or the matplotlib > Tim> internals so I couldn't trace this bug deeper into the > Tim> libraries. Can anyone shed some light on what's going on? If > Tim> we can get the arrow keys working is there a chance of > Tim> getting them into the standard distribution (assuming we had > Tim> all backends working)? > > Absolutely. It might be nice to enable some standard keyboard > navigation too. OK well I'll play around with this some more and I'll get back to you once I have what I think is a complete, working patch. Cheers, Tim Leslie > > JDH > `- |
From: Tim L. <ti...@cs...> - 2005-04-13 15:02:48
|
Just to follow up on this, I made the required changes to the other backends and they worked fine. GTK and GTKAgg had the same broken behaviour while TkAgg, WX and WXAgg worked fine (don't have qt installed). I'll bring all my libraries up to date (thanks for 0.80 tonight) and dive into the pygtk stuff a bit deeper to see if I can find out what's breaking. Having looked through a bit more mpl code I'd just like to say that I'm very impressed with how simple it is to read. After working out what to change in GTK, it followed an identical pattern in the other backends which was very nice to see. Cheers, Tim Leslie On Thu, 14 Apr 2005, Tim Leslie <ti...@cs...> wrote... > On Wed, 13 Apr 2005, John Hunter <jdh...@ac...> wrote... > > > >>>>> "Tim" == Tim Leslie <ti...@cs...> writes: > > > > Tim> This all works fine except that the down key doesn't register > > Tim> as released. After registering the down key press, no other > > Tim> key events register until you hit the up key, at which point > > Tim> the key release triggers for the up. > > > > It works fine for me -- what is your pygtk version and OS? > > I'm using pygtk 2.2.0 on linux. > > AFAICT pygtk 2.0, this is running on ubuntu unstable. > > > > > You might put some debug print statements to print event.keyval in > > _get_key to see if an event is being triggered at the gtk level. > > OK, I'll have a play with that. > > > > > Could it be a bad keyboard??? > > Yep :) Well, maybe. The down key works in every other app I use, but I've > had problems with this keyboard in strange ways before, so I wouldn't put > it past it. I'll try it out on another machine when I get a chance and see > how it goes. It's a laptop, so I can't really change the keyboard. (hmm, > maybe a usb external one, if I had one) > > > > > Tim> I really don't know a lot about Gtk or the matplotlib > > Tim> internals so I couldn't trace this bug deeper into the > > Tim> libraries. Can anyone shed some light on what's going on? If > > Tim> we can get the arrow keys working is there a chance of > > Tim> getting them into the standard distribution (assuming we had > > Tim> all backends working)? > > > > Absolutely. It might be nice to enable some standard keyboard > > navigation too. > > OK well I'll play around with this some more and I'll get back to you once > I have what I think is a complete, working patch. > > Cheers, > > Tim Leslie > > > > > JDH > > > `- > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > `- |
From: Tim L. <ti...@cs...> - 2005-04-13 16:49:31
|
OK, here are the diffs for each backend: ~/src/matplotlib-0.80/lib/matplotlib/backends/backend_gtk.py 109,112d108 < 65361 : 'left', < 65362 : 'up', < 65363 : 'right', < 65364 : 'down', ~/src/matplotlib-0.80/lib/matplotlib/backends/backend_wx.py 675,678d674 < 316 : 'left', < 317 : 'up', < 318 : 'right', < 319 : 'down', ~/src/matplotlib-0.80/lib/matplotlib/backends/backend_tkagg.py 99,102d98 < 65361 : 'left', < 65362 : 'up', < 65363 : 'right', < 65364 : 'down', ~/src/matplotlib-0.80/lib/matplotlib/backends/backend_qt.py 74,77d73 < qt.Qt.Key_Left : 'left', < qt.Qt.Key_Up : 'up', < qt.Qt.Key_Right : 'right', < qt.Qt.Key_Down : 'down', As you can see, it's reasonably straightforward to add these extra keys, so if anyone feels creative and wants other keys added, this should give an idea of what needs changing. As for my problem with gtk and the down key, I've rebuilt pygtk (2.6.1), installed matplotlib 0.80, and the problem is still there. I whipped up a trivial pygtk program which was a window which connected to key press events and it worked just fine, so it seems that there's something that matplotlib is doing which triggers the bug (that's not to say the bug is in mpl of course). I'm guessing there is something in my system setup which is flakey and causing it to happen, but it's 3am and I'm tired so I'll just live with it for now :) Cheers, Tim Leslie On Thu, 14 Apr 2005, Tim Leslie <ti...@cs...> wrote... > Just to follow up on this, I made the required changes to the other > backends and they worked fine. GTK and GTKAgg had the same broken > behaviour while TkAgg, WX and WXAgg worked fine (don't have qt installed). > > I'll bring all my libraries up to date (thanks for 0.80 tonight) and dive > into the pygtk stuff a bit deeper to see if I can find out what's > breaking. > > Having looked through a bit more mpl code I'd just like to say that I'm > very impressed with how simple it is to read. After working out what to > change in GTK, it followed an identical pattern in the other backends > which was very nice to see. > > Cheers, > > Tim Leslie > > On Thu, 14 Apr 2005, Tim Leslie <ti...@cs...> wrote... > > > On Wed, 13 Apr 2005, John Hunter <jdh...@ac...> wrote... > > > > > >>>>> "Tim" == Tim Leslie <ti...@cs...> writes: > > > > > > Tim> This all works fine except that the down key doesn't register > > > Tim> as released. After registering the down key press, no other > > > Tim> key events register until you hit the up key, at which point > > > Tim> the key release triggers for the up. > > > > > > It works fine for me -- what is your pygtk version and OS? > > > I'm using pygtk 2.2.0 on linux. > > > > AFAICT pygtk 2.0, this is running on ubuntu unstable. > > > > > > > > You might put some debug print statements to print event.keyval in > > > _get_key to see if an event is being triggered at the gtk level. > > > > OK, I'll have a play with that. > > > > > > > > Could it be a bad keyboard??? > > > > Yep :) Well, maybe. The down key works in every other app I use, but I've > > had problems with this keyboard in strange ways before, so I wouldn't put > > it past it. I'll try it out on another machine when I get a chance and see > > how it goes. It's a laptop, so I can't really change the keyboard. (hmm, > > maybe a usb external one, if I had one) > > > > > > > > Tim> I really don't know a lot about Gtk or the matplotlib > > > Tim> internals so I couldn't trace this bug deeper into the > > > Tim> libraries. Can anyone shed some light on what's going on? If > > > Tim> we can get the arrow keys working is there a chance of > > > Tim> getting them into the standard distribution (assuming we had > > > Tim> all backends working)? > > > > > > Absolutely. It might be nice to enable some standard keyboard > > > navigation too. > > > > OK well I'll play around with this some more and I'll get back to you once > > I have what I think is a complete, working patch. > > > > Cheers, > > > > Tim Leslie > > > > > > > > JDH > > > > > `- > > > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from real users. > > Discover which products truly live up to the hype. Start reading now. > > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > `- > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > `- |
From: John H. <jdh...@ac...> - 2005-04-13 18:23:35
|
>>>>> "Tim" == Tim Leslie <ti...@cs...> writes: Tim> OK, here are the diffs for each backend: OK, I added these to my local tree. Thanks for tracking these down across backends. Now if Gregory or someone can just get these for fltk, we'll be done. Tim> As for my problem with gtk and the down key, I've rebuilt Tim> pygtk (2.6.1), installed matplotlib 0.80, and the problem is Tim> still there. I whipped up a trivial pygtk program which was a Tim> window which connected to key press events and it worked just Tim> fine, so it seems that there's something that matplotlib is Tim> doing which triggers the bug (that's not to say the bug is in Tim> mpl of course). I'm guessing there is something in my system Tim> setup which is flakey and causing it to happen, but it's 3am Tim> and I'm tired so I'll just live with it for now :) I have seen on some GUIs that different keyvals are sent for the same key, so do check and see what event.keyval is reporting; you may need to add additional dictionary entries to keyvald. I also tried to replicate the problem on pygtk-2.0.0 on win32, but down-arrow press and release worked as they should. JDH |
From: Werner F. B. <wer...@fr...> - 2005-04-13 18:51:20
|
Hi Tim and John, I didn't catch on to this earlier but shouldn't the backend_wx.py use something along these lines: keyvald = {wx.WXK_CONTROL : 'control', wx.WXK_SHIFT : 'shift', wx.WXK_ALT : 'alt', wx.WXK_LEFT : 'left', wx.WXK_UP : 'up', wx.WXK_RIGHT : 'right', wx.WXK_DOWN : 'down', } For more WXK codes see the wx demo Process and Events/KeyEvents. See you Werner Tim Leslie wrote: > OK, here are the diffs for each backend: > > ~/src/matplotlib-0.80/lib/matplotlib/backends/backend_gtk.py > 109,112d108 > < 65361 : 'left', > < 65362 : 'up', > < 65363 : 'right', > < 65364 : 'down', > > ~/src/matplotlib-0.80/lib/matplotlib/backends/backend_wx.py > 675,678d674 > < 316 : 'left', > < 317 : 'up', > < 318 : 'right', > < 319 : 'down', > > ~/src/matplotlib-0.80/lib/matplotlib/backends/backend_tkagg.py > 99,102d98 > < 65361 : 'left', > < 65362 : 'up', > < 65363 : 'right', > < 65364 : 'down', > > ~/src/matplotlib-0.80/lib/matplotlib/backends/backend_qt.py > 74,77d73 > < qt.Qt.Key_Left : 'left', > < qt.Qt.Key_Up : 'up', > < qt.Qt.Key_Right : 'right', > < qt.Qt.Key_Down : 'down', > > As you can see, it's reasonably straightforward to add these extra keys, > so if anyone feels creative and wants other keys added, this should give > an idea of what needs changing. > > As for my problem with gtk and the down key, I've rebuilt pygtk (2.6.1), > installed matplotlib 0.80, and the problem is still there. I whipped up a > trivial pygtk program which was a window which connected to key press > events and it worked just fine, so it seems that there's something that > matplotlib is doing which triggers the bug (that's not to say the bug is > in mpl of course). I'm guessing there is something in my system setup > which is flakey and causing it to happen, but it's 3am and I'm tired so > I'll just live with it for now :) > > Cheers, > > Tim Leslie > > On Thu, 14 Apr 2005, Tim Leslie <ti...@cs...> wrote... > > >>Just to follow up on this, I made the required changes to the other >>backends and they worked fine. GTK and GTKAgg had the same broken >>behaviour while TkAgg, WX and WXAgg worked fine (don't have qt installed). >> >>I'll bring all my libraries up to date (thanks for 0.80 tonight) and dive >>into the pygtk stuff a bit deeper to see if I can find out what's >>breaking. >> >>Having looked through a bit more mpl code I'd just like to say that I'm >>very impressed with how simple it is to read. After working out what to >>change in GTK, it followed an identical pattern in the other backends >>which was very nice to see. >> >>Cheers, >> >>Tim Leslie >> >>On Thu, 14 Apr 2005, Tim Leslie <ti...@cs...> wrote... >> >> >>>On Wed, 13 Apr 2005, John Hunter <jdh...@ac...> wrote... >>> >>> >>>>>>>>>"Tim" == Tim Leslie <ti...@cs...> writes: >>>> >>>> Tim> This all works fine except that the down key doesn't register >>>> Tim> as released. After registering the down key press, no other >>>> Tim> key events register until you hit the up key, at which point >>>> Tim> the key release triggers for the up. >>>> >>>>It works fine for me -- what is your pygtk version and OS? >>>>I'm using pygtk 2.2.0 on linux. >>> >>>AFAICT pygtk 2.0, this is running on ubuntu unstable. >>> >>> >>>>You might put some debug print statements to print event.keyval in >>>>_get_key to see if an event is being triggered at the gtk level. >>> >>>OK, I'll have a play with that. >>> >>> >>>>Could it be a bad keyboard??? >>> >>>Yep :) Well, maybe. The down key works in every other app I use, but I've >>>had problems with this keyboard in strange ways before, so I wouldn't put >>>it past it. I'll try it out on another machine when I get a chance and see >>>how it goes. It's a laptop, so I can't really change the keyboard. (hmm, >>>maybe a usb external one, if I had one) >>> >>> >>>> Tim> I really don't know a lot about Gtk or the matplotlib >>>> Tim> internals so I couldn't trace this bug deeper into the >>>> Tim> libraries. Can anyone shed some light on what's going on? If >>>> Tim> we can get the arrow keys working is there a chance of >>>> Tim> getting them into the standard distribution (assuming we had >>>> Tim> all backends working)? >>>> >>>>Absolutely. It might be nice to enable some standard keyboard >>>>navigation too. >>> >>>OK well I'll play around with this some more and I'll get back to you once >>>I have what I think is a complete, working patch. >>> >>>Cheers, >>> >>>Tim Leslie >>> >>> >>>>JDH >>>> >>> >>>`- >>> >>> >>>------------------------------------------------------- >>>SF email is sponsored by - The IT Product Guide >>>Read honest & candid reviews on hundreds of IT Products from real users. >>>Discover which products truly live up to the hype. Start reading now. >>>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >>>_______________________________________________ >>>Matplotlib-users mailing list >>>Mat...@li... >>>https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >> >>`- >> >> >>------------------------------------------------------- >>SF email is sponsored by - The IT Product Guide >>Read honest & candid reviews on hundreds of IT Products from real users. >>Discover which products truly live up to the hype. Start reading now. >>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >>_______________________________________________ >>Matplotlib-users mailing list >>Mat...@li... >>https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > > `- > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click |
From: Tim L. <ti...@cs...> - 2005-04-14 01:06:11
|
On Wed, 13 Apr 2005, Werner F. Bruhin <wer...@fr...> wrote... > Hi Tim and John, > > I didn't catch on to this earlier but shouldn't the backend_wx.py use > something along these lines: > > keyvald = {wx.WXK_CONTROL : 'control', > wx.WXK_SHIFT : 'shift', > wx.WXK_ALT : 'alt', > wx.WXK_LEFT : 'left', > wx.WXK_UP : 'up', > wx.WXK_RIGHT : 'right', > wx.WXK_DOWN : 'down', > } > > For more WXK codes see the wx demo Process and Events/KeyEvents. I suppose that would be the sane thing to do, yes. Presumably we can also find similar codes for GTK. I'll have a look for them today. Tim > > See you > Werner > > > Tim Leslie wrote: > >OK, here are the diffs for each backend: > > > >~/src/matplotlib-0.80/lib/matplotlib/backends/backend_gtk.py > >109,112d108 > >< 65361 : 'left', > >< 65362 : 'up', > >< 65363 : 'right', > >< 65364 : 'down', > > > >~/src/matplotlib-0.80/lib/matplotlib/backends/backend_wx.py > >675,678d674 > >< 316 : 'left', > >< 317 : 'up', > >< 318 : 'right', > >< 319 : 'down', > > > >~/src/matplotlib-0.80/lib/matplotlib/backends/backend_tkagg.py > >99,102d98 > >< 65361 : 'left', > >< 65362 : 'up', > >< 65363 : 'right', > >< 65364 : 'down', > > > >~/src/matplotlib-0.80/lib/matplotlib/backends/backend_qt.py > >74,77d73 > >< qt.Qt.Key_Left : 'left', > >< qt.Qt.Key_Up : 'up', > >< qt.Qt.Key_Right : 'right', > >< qt.Qt.Key_Down : 'down', > > > >As you can see, it's reasonably straightforward to add these extra keys, > >so if anyone feels creative and wants other keys added, this should give > >an idea of what needs changing. > > > >As for my problem with gtk and the down key, I've rebuilt pygtk (2.6.1), > >installed matplotlib 0.80, and the problem is still there. I whipped up a > >trivial pygtk program which was a window which connected to key press > >events and it worked just fine, so it seems that there's something that > >matplotlib is doing which triggers the bug (that's not to say the bug is > >in mpl of course). I'm guessing there is something in my system setup > >which is flakey and causing it to happen, but it's 3am and I'm tired so > >I'll just live with it for now :) > > > >Cheers, > > > >Tim Leslie > > > >On Thu, 14 Apr 2005, Tim Leslie <ti...@cs...> wrote... > > > > > >>Just to follow up on this, I made the required changes to the other > >>backends and they worked fine. GTK and GTKAgg had the same broken > >>behaviour while TkAgg, WX and WXAgg worked fine (don't have qt installed). > >> > >>I'll bring all my libraries up to date (thanks for 0.80 tonight) and dive > >>into the pygtk stuff a bit deeper to see if I can find out what's > >>breaking. > >> > >>Having looked through a bit more mpl code I'd just like to say that I'm > >>very impressed with how simple it is to read. After working out what to > >>change in GTK, it followed an identical pattern in the other backends > >>which was very nice to see. > >> > >>Cheers, > >> > >>Tim Leslie > >> > >>On Thu, 14 Apr 2005, Tim Leslie <ti...@cs...> wrote... > >> > >> > >>>On Wed, 13 Apr 2005, John Hunter <jdh...@ac...> wrote... > >>> > >>> > >>>>>>>>>"Tim" == Tim Leslie <ti...@cs...> writes: > >>>> > >>>> Tim> This all works fine except that the down key doesn't register > >>>> Tim> as released. After registering the down key press, no other > >>>> Tim> key events register until you hit the up key, at which point > >>>> Tim> the key release triggers for the up. > >>>> > >>>>It works fine for me -- what is your pygtk version and OS? > >>>>I'm using pygtk 2.2.0 on linux. > >>> > >>>AFAICT pygtk 2.0, this is running on ubuntu unstable. > >>> > >>> > >>>>You might put some debug print statements to print event.keyval in > >>>>_get_key to see if an event is being triggered at the gtk level. > >>> > >>>OK, I'll have a play with that. > >>> > >>> > >>>>Could it be a bad keyboard??? > >>> > >>>Yep :) Well, maybe. The down key works in every other app I use, but I've > >>>had problems with this keyboard in strange ways before, so I wouldn't put > >>>it past it. I'll try it out on another machine when I get a chance and > >>>see > >>>how it goes. It's a laptop, so I can't really change the keyboard. (hmm, > >>>maybe a usb external one, if I had one) > >>> > >>> > >>>> Tim> I really don't know a lot about Gtk or the matplotlib > >>>> Tim> internals so I couldn't trace this bug deeper into the > >>>> Tim> libraries. Can anyone shed some light on what's going on? If > >>>> Tim> we can get the arrow keys working is there a chance of > >>>> Tim> getting them into the standard distribution (assuming we had > >>>> Tim> all backends working)? > >>>> > >>>>Absolutely. It might be nice to enable some standard keyboard > >>>>navigation too. > >>> > >>>OK well I'll play around with this some more and I'll get back to you > >>>once > >>>I have what I think is a complete, working patch. > >>> > >>>Cheers, > >>> > >>>Tim Leslie > >>> > >>> > >>>>JDH > >>>> > >>> > >>>`- > >>> > >>> > >>>------------------------------------------------------- > >>>SF email is sponsored by - The IT Product Guide > >>>Read honest & candid reviews on hundreds of IT Products from real users. > >>>Discover which products truly live up to the hype. Start reading now. > >>>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > >>>_______________________________________________ > >>>Matplotlib-users mailing list > >>>Mat...@li... > >>>https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >>> > >> > >>`- > >> > >> > >>------------------------------------------------------- > >>SF email is sponsored by - The IT Product Guide > >>Read honest & candid reviews on hundreds of IT Products from real users. > >>Discover which products truly live up to the hype. Start reading now. > >>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > >>_______________________________________________ > >>Matplotlib-users mailing list > >>Mat...@li... > >>https://lists.sourceforge.net/lists/listinfo/matplotlib-users > >> > > > >`- > > > > > >------------------------------------------------------- > >SF email is sponsored by - The IT Product Guide > >Read honest & candid reviews on hundreds of IT Products from real users. > >Discover which products truly live up to the hype. Start reading now. > >http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > `- |
From: John G. <jn...@eu...> - 2005-04-14 09:59:09
|
For gtk you can use something like this: keyvald = {} for name in ['Up', 'Down', 'Left', 'Right']: keyvald[name.lower()] = gtk.gdk.keyval_from_name(name) John Tim Leslie wrote: > On Wed, 13 Apr 2005, Werner F. Bruhin <wer...@fr...> wrote... > > > Hi Tim and John, > > > > I didn't catch on to this earlier but shouldn't the backend_wx.py use > > something along these lines: > > > > keyvald = {wx.WXK_CONTROL : 'control', > > wx.WXK_SHIFT : 'shift', > > wx.WXK_ALT : 'alt', > > wx.WXK_LEFT : 'left', > > wx.WXK_UP : 'up', > > wx.WXK_RIGHT : 'right', > > wx.WXK_DOWN : 'down', > > } > > > > For more WXK codes see the wx demo Process and Events/KeyEvents. > > I suppose that would be the sane thing to do, yes. Presumably we can also > find similar codes for GTK. I'll have a look for them today. > > Tim > > > > > See you > > Werner > > > > > > Tim Leslie wrote: > > >OK, here are the diffs for each backend: > > > > > >~/src/matplotlib-0.80/lib/matplotlib/backends/backend_gtk.py > > >109,112d108 > > >< 65361 : 'left', > > >< 65362 : 'up', > > >< 65363 : 'right', > > >< 65364 : 'down', > > > > > >~/src/matplotlib-0.80/lib/matplotlib/backends/backend_wx.py > > >675,678d674 > > >< 316 : 'left', > > >< 317 : 'up', > > >< 318 : 'right', > > >< 319 : 'down', > > > > > >~/src/matplotlib-0.80/lib/matplotlib/backends/backend_tkagg.py > > >99,102d98 > > >< 65361 : 'left', > > >< 65362 : 'up', > > >< 65363 : 'right', > > >< 65364 : 'down', > > > > > >~/src/matplotlib-0.80/lib/matplotlib/backends/backend_qt.py > > >74,77d73 > > >< qt.Qt.Key_Left : 'left', > > >< qt.Qt.Key_Up : 'up', > > >< qt.Qt.Key_Right : 'right', > > >< qt.Qt.Key_Down : 'down', > > > > > >As you can see, it's reasonably straightforward to add these extra > keys, > > >so if anyone feels creative and wants other keys added, this should > give > > >an idea of what needs changing. > > > > > >As for my problem with gtk and the down key, I've rebuilt pygtk > (2.6.1), > > >installed matplotlib 0.80, and the problem is still there. I > whipped up a > > >trivial pygtk program which was a window which connected to key press > > >events and it worked just fine, so it seems that there's something > that > > >matplotlib is doing which triggers the bug (that's not to say the > bug is > > >in mpl of course). I'm guessing there is something in my system setup > > >which is flakey and causing it to happen, but it's 3am and I'm > tired so > > >I'll just live with it for now :) > > > > > >Cheers, > > > > > >Tim Leslie > > > > > >On Thu, 14 Apr 2005, Tim Leslie <ti...@cs...> wrote... > > > > > > > > >>Just to follow up on this, I made the required changes to the other > > >>backends and they worked fine. GTK and GTKAgg had the same broken > > >>behaviour while TkAgg, WX and WXAgg worked fine (don't have qt > installed). > > >> > > >>I'll bring all my libraries up to date (thanks for 0.80 tonight) > and dive > > >>into the pygtk stuff a bit deeper to see if I can find out what's > > >>breaking. > > >> > > >>Having looked through a bit more mpl code I'd just like to say > that I'm > > >>very impressed with how simple it is to read. After working out > what to > > >>change in GTK, it followed an identical pattern in the other backends > > >>which was very nice to see. > > >> > > >>Cheers, > > >> > > >>Tim Leslie > > >> > > >>On Thu, 14 Apr 2005, Tim Leslie <ti...@cs...> wrote... > > >> > > >> > > >>>On Wed, 13 Apr 2005, John Hunter <jdh...@ac...> > wrote... > > >>> > > >>> > > >>>>>>>>>"Tim" == Tim Leslie <ti...@cs...> writes: > > >>>> > > >>>> Tim> This all works fine except that the down key doesn't > register > > >>>> Tim> as released. After registering the down key press, no > other > > >>>> Tim> key events register until you hit the up key, at which > point > > >>>> Tim> the key release triggers for the up. > > >>>> > > >>>>It works fine for me -- what is your pygtk version and OS? > > >>>>I'm using pygtk 2.2.0 on linux. > > >>> > > >>>AFAICT pygtk 2.0, this is running on ubuntu unstable. > > >>> > > >>> > > >>>>You might put some debug print statements to print event.keyval in > > >>>>_get_key to see if an event is being triggered at the gtk level. > > >>> > > >>>OK, I'll have a play with that. > > >>> > > >>> > > >>>>Could it be a bad keyboard??? > > >>> > > >>>Yep :) Well, maybe. The down key works in every other app I use, > but I've > > >>>had problems with this keyboard in strange ways before, so I > wouldn't put > > >>>it past it. I'll try it out on another machine when I get a > chance and > > >>>see > > >>>how it goes. It's a laptop, so I can't really change the > keyboard. (hmm, > > >>>maybe a usb external one, if I had one) > > >>> > > >>> > > >>>> Tim> I really don't know a lot about Gtk or the matplotlib > > >>>> Tim> internals so I couldn't trace this bug deeper into the > > >>>> Tim> libraries. Can anyone shed some light on what's going > on? If > > >>>> Tim> we can get the arrow keys working is there a chance of > > >>>> Tim> getting them into the standard distribution (assuming we > had > > >>>> Tim> all backends working)? > > >>>> > > >>>>Absolutely. It might be nice to enable some standard keyboard > > >>>>navigation too. > > >>> > > >>>OK well I'll play around with this some more and I'll get back to > you > > >>>once > > >>>I have what I think is a complete, working patch. > > >>> > > >>>Cheers, > > >>> > > >>>Tim Leslie > > >>> > > >>> > > >>>>JDH > > >>>> > > >>> > > >>>`- > > >>> > > >>> > > >>>------------------------------------------------------- > > >>>SF email is sponsored by - The IT Product Guide > > >>>Read honest & candid reviews on hundreds of IT Products from real > users. > > >>>Discover which products truly live up to the hype. Start reading > now. > > >>>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > <http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click> > > >>>_______________________________________________ > > >>>Matplotlib-users mailing list > > >>>Mat...@li... > > >>>https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > >>> > > >> > > >>`- > > >> > > >> > > >>------------------------------------------------------- > > >>SF email is sponsored by - The IT Product Guide > > >>Read honest & candid reviews on hundreds of IT Products from real > users. > > >>Discover which products truly live up to the hype. Start reading now. > > >>http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > <http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click> > > >>_______________________________________________ > > >>Matplotlib-users mailing list > > >>Mat...@li... > > >>https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > >> > > > > > >`- > > > > > > > > >------------------------------------------------------- > > >SF email is sponsored by - The IT Product Guide > > >Read honest & candid reviews on hundreds of IT Products from real > users. > > >Discover which products truly live up to the hype. Start reading now. > > >http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > <http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click> > > > > > > > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from real > users. > > Discover which products truly live up to the hype. Start reading now. > > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > <http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click> > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > `- > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > <http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click> > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |