ginput default mouse configuration

Hello,

The new ginput is great, and I’m going to start using it instead of my original implementation. The one problem is on my (and many) laptops, it is in practice hard to middle click, and I often find myself accidentally clicking or removing a click.

It would be nice (and should be straightforward) if there was a command-line argument or two to switch the roles of the mouse buttons, so we could type something like

ginput(0,0, add=1, remove=3, finish=2)

to swap the roles of the right and middle mouse buttons.

Cheers!

Jack

Hello again,

I’m not an official dev with commit ability (though I may be committable), but I modified figure.py and blocking_input.py to allow us to do exactly this. Any chance it could make it to the next release?

http://sites.google.com/site/jacksankey/files/matplotlib.zip?attredirects=0

Notes:

-It would be simple to extend this to allow us to assign the keyboard keys as well.

-It’s probably worth changing the logical order or add some extra logic so that the user can’t have one button assigned to two functions (this is probably better to allow us to change one of the buttons and have the others find slots accordingly)

-I can’t seem to generate the button2 event (middle click) with my logitech thumb-wheel mouse on XP

-I can’t get any keyboard events to work even when the figure’s focused and I’ve been clicking for awhile.

Let me know if I can help. I certainly wouldn’t mind committing this myself, should the opportunity arise. :slight_smile:

Regards,

-Jack

···

On Tue, Aug 11, 2009 at 4:09 PM, Jack Sankey <jack.sankey@…149…> wrote:

Hello,

The new ginput is great, and I’m going to start using it instead of my original implementation. The one problem is on my (and many) laptops, it is in practice hard to middle click, and I often find myself accidentally clicking or removing a click.

It would be nice (and should be straightforward) if there was a command-line argument or two to switch the roles of the mouse buttons, so we could type something like

ginput(0,0, add=1, remove=3, finish=2)

to swap the roles of the right and middle mouse buttons.

Cheers!

Jack

(correction: I can get the keyboard to click and remove clicks, but can’t get the ‘enter’ event to fire. Maybe windows has a different binding?)

···

On Tue, Aug 11, 2009 at 4:50 PM, Jack Sankey <jack.sankey@…149…> wrote:

Hello again,

I’m not an official dev with commit ability (though I may be committable), but I modified figure.py and blocking_input.py to allow us to do exactly this. Any chance it could make it to the next release?

http://sites.google.com/site/jacksankey/files/matplotlib.zip?attredirects=0

Notes:

-It would be simple to extend this to allow us to assign the keyboard keys as well.

-It’s probably worth changing the logical order or add some extra logic so that the user can’t have one button assigned to two functions (this is probably better to allow us to change one of the buttons and have the others find slots accordingly)

-I can’t seem to generate the button2 event (middle click) with my logitech thumb-wheel mouse on XP

-I can’t get any keyboard events to work even when the figure’s focused and I’ve been clicking for awhile.

Let me know if I can help. I certainly wouldn’t mind committing this myself, should the opportunity arise. :slight_smile:

Regards,

-Jack

On Tue, Aug 11, 2009 at 4:09 PM, Jack Sankey <jack.sankey@…149…> wrote:

Hello,

The new ginput is great, and I’m going to start using it instead of my original implementation. The one problem is on my (and many) laptops, it is in practice hard to middle click, and I often find myself accidentally clicking or removing a click.

It would be nice (and should be straightforward) if there was a command-line argument or two to switch the roles of the mouse buttons, so we could type something like

ginput(0,0, add=1, remove=3, finish=2)

to swap the roles of the right and middle mouse buttons.

Cheers!

Jack

Sorry for spamming, but I have another addition to BlockingMouseInput.add_click, that fixes the problem of the graphics jumping around while ginputting. This makes it much easier to zoom in on an imshow() plot and click a bunch of points, for example (it used to zoom all the way out!):

def add_click(self,event):

“”"

This add the coordinates of an event to the list of clicks

“”"

self.clicks.append((event.xdata,event.ydata))

verbose.report(“input %i: %f,%f” %

(len(self.clicks),event.xdata, event.ydata))

If desired plot up click

if self.show_clicks:

make sure we don’t mess with the axes zoom

xlim = event.inaxes.get_xlim()

ylim = event.inaxes.get_ylim()

plot the clicks

self.marks.extend(

event.inaxes.plot([event.xdata,], [event.ydata,], ‘r+’) )

before we draw, make sure to reset the limits

event.inaxes.set_xlim(xlim)

event.inaxes.set_ylim(ylim)

self.fig.canvas.draw()

For those of us scoring at home, you may want to post an svn diff
against HEAD with which we can patch our distros, and an example file
or two or a very clear sequence of commands to illustrate the new
functionality before and after. The ginput work is the product of one
or two developers out of a dozen, the rest of us have only limited
experience with it and less knowledge of the internals, so clear
"instructions for dummies" and easy installations via proper svn diffs
will help us experiment with your work.

  http://matplotlib.sourceforge.net/faq/howto_faq.html#contributing-howto

Looking forward to it,
JDH

···

On Tue, Aug 11, 2009 at 6:53 PM, Jack Sankey<jack.sankey@...149...> wrote:

Sorry for spamming, but I have another addition to
BlockingMouseInput.add_click, that fixes the problem of the graphics jumping
around while ginputting. This makes it much easier to zoom in on an imshow()
plot and click a bunch of points, for example (it used to zoom all the way
out!):

Hi John,

Now I remember why I never figured out how to contribute. I don’t have a Visual Studio 2003 compiler (only 2008 is available from microsoft any more) and I don’t have time to figure out all the flags and so on to compile. I do have Mingw32 but no jumbling of [“python.exe”, “setup.py”, “install”, “-c”, “mingw32”] will start it compiling, with and without quotes.

Anyway, I tried different things to get a diff file with the current source for about an hour but I really need to get back to my data crunching now.

I would like to contribute but only on the interface/python front. Is it possible to svn checkout just the *.py files or a way around needing to compile the binaries?

Regards,
Jack

···

On Tue, Aug 11, 2009 at 8:00 PM, John Hunter <jdh2358@…149…> wrote:

On Tue, Aug 11, 2009 at 6:53 PM, Jack Sankey<jack.sankey@…149…> wrote:

Sorry for spamming, but I have another addition to

BlockingMouseInput.add_click, that fixes the problem of the graphics jumping

around while ginputting. This makes it much easier to zoom in on an imshow()

plot and click a bunch of points, for example (it used to zoom all the way

out!):

For those of us scoring at home, you may want to post an svn diff

against HEAD with which we can patch our distros, and an example file

or two or a very clear sequence of commands to illustrate the new

functionality before and after. The ginput work is the product of one

or two developers out of a dozen, the rest of us have only limited

experience with it and less knowledge of the internals, so clear

“instructions for dummies” and easy installations via proper svn diffs

will help us experiment with your work.

http://matplotlib.sourceforge.net/faq/howto_faq.html#contributing-howto

Looking forward to it,

JDH

Hey Jack,

If you cannot send an 'svn diff' of your changes, would you mind sending
the modified files all together? It is hard to review changes when
gathering them from various mails: so easy to forget a change.

Cheers,

Ga�l

···

On Tue, Aug 11, 2009 at 07:53:29PM -0400, Jack Sankey wrote:

   Sorry for spamming, but I have another addition to
   BlockingMouseInput.add_click, that fixes the problem of the graphics
   jumping around while ginputting. This makes it much easier to zoom in on
   an imshow() plot and click a bunch of points, for example (it used to zoom
   all the way out!):

Hello Gael,

Okay, I’ve updated the two files I modified here:

http://sites.google.com/site/jacksankey/files/matplotlib.zip?attredirects=0

Sorry I can’t figure out how to compile. I wish it was possible to have an SVN containing also the windows binaries. Too bad we all can’t just run Linux.

Anyway, I tested the pants off this using an imshow() color plot this morning, and it works well on windows XP/wxAgg. There are two things worth mentioning:

  • For some reason, the enter key does not generate an event for me. I’ve added “escape” as another possible keyboard stop event generator.

  • The backspace key causes the plot to undo a zoom. This confused me for an hour. Use delete!

  • I’m fairly certain the mouse numbers are different for windows. I can’t make the middle mouse button do anything.

If you don’t wind up adding all these changes, in the very least for the upcoming release, can you please add “escape” to the list of keys that will exit the collection of data points? That would amount to changing one line in key_event() from

elif key == ‘enter’

to

elif key in [‘escape’, ‘enter’]:

The third point above is the reason I looked into this in the first place; I couldn’t stop collecting! :slight_smile: Adding ‘escape’ would make ginput() functional enough. (I also use key = event.key.lower() to be safe.)

Thanks!

-Jack

···

On Thu, Aug 13, 2009 at 1:45 PM, Gael Varoquaux <gael.varoquaux@…427…> wrote:

On Tue, Aug 11, 2009 at 07:53:29PM -0400, Jack Sankey wrote:

Sorry for spamming, but I have another addition to

BlockingMouseInput.add_click, that fixes the problem of the graphics

jumping around while ginputting. This makes it much easier to zoom in on

an imshow() plot and click a bunch of points, for example (it used to zoom

all the way out!):

Hey Jack,

If you cannot send an ‘svn diff’ of your changes, would you mind sending

the modified files all together? It is hard to review changes when

gathering them from various mails: so easy to forget a change.

Cheers,

Gaël

Hi Jack,

I've tried to apply your code properly. Because it was not a patch,
but a simple code file submission (and the original files have changed
since your submission) and because I did not write the original ginput
code, it was touch sledding to apply the patch. I think I got it
right, but I would like people who use ginput and blocking input to
give it a test drive (I did what basic tests I could, not being a
power user).

Thanks for the submission,
JDH

···

On Mon, Aug 17, 2009 at 11:24 AM, Jack Sankey<jack.sankey@...149...> wrote:

Hello Gael,
Okay, I've updated the two files I modified here:
http://sites.google.com/site/jacksankey/files/matplotlib.zip?attredirects=0
Sorry I can't figure out how to compile. I wish it was possible to have an
SVN containing also the windows binaries. Too bad we all can't just run
Linux.
Anyway, I tested the pants off this using an imshow() color plot this
morning, and it works well on windows XP/wxAgg. There are two things worth
mentioning:
- For some reason, the enter key does not generate an event for me. I've
added "escape" as another possible keyboard stop event generator.
- The backspace key causes the plot to undo a zoom. This confused me for an
hour. Use delete!
- I'm fairly certain the mouse numbers are different for windows. I can't
make the middle mouse button do anything.
If you don't wind up adding all these changes, in the very least for the
upcoming release, can you please add "escape" to the list of keys that will
exit the collection of data points? That would amount to changing one line
in key_event() from
elif key == 'enter'
to
elif key in ['escape', 'enter']:
The third point above is the reason I looked into this in the first place; I
couldn't stop collecting! :slight_smile: Adding 'escape' would make ginput() functional
enough. (I also use key = event.key.lower() to be safe.)
Thanks!
-Jack

Thank John you for doing the grunt work. It pushed me enough to do the
review that you had asked for. I am attaching a patch correcting a bug,
as well as improving the docs, and fixing a few unecessary imports.

As a side note, you guys should run pyflakes on your codebase every once
in a while. You have a lot of unused imports. Also, there seems to be
bigger problems such as

    finance.py:169: undefined name 'url'
    font_manager.py:221: undefined name 'WindowsError'
    config/checkdep.py:67: undefined name 'verbose'
    cbook.py:787: undefined name '__Full'
    cbook.py:1414: undefined name 'glob'
    cbook.py:1577: undefined name 'x'
    cbook.py:1577: undefined name 'y'
    cbook.py:1577: undefined name 'xi'
    cbook.py:1577: undefined name 'extrap'

And many others that I am passing.

These might be bugs, or might not. I didn't take the time to check.

Cheers,

Gaël

ginput.diff (1.94 KB)

···

On Sat, Aug 29, 2009 at 10:45:31PM -0500, John Hunter wrote:

I've tried to apply your code properly. Because it was not a patch,
but a simple code file submission (and the original files have changed
since your submission) and because I did not write the original ginput
code, it was touch sledding to apply the patch. I think I got it
right, but I would like people who use ginput and blocking input to
give it a test drive (I did what basic tests I could, not being a
power user).