Not seeing middle mouse button events

Hi Everyone,

This is my first post, so I'll apologize in advance for any inadvertent lapse in manners.

I'm using matplotlib 0.98.5.2, wxPython version 2.8-msw-unicode, on Windows XP Professional x64 at work (and 32bit at home). At work I have a plain old Dell 2 button mouse with a scroll wheel which you can scroll or click as a middle mouse button. At home I have an equivalent mouse from Logitec. Both mice exhibit useful functionality for the "middle button" in browsers. And I did install the latest Logitec drivers at home and specifically set the scroll click to have the functionality of a middle mouse button.

In all cases, home or work, I failed to detect a middle mouse button press or release event.

I've attached an example program and copied the text below.

If anyone could please check to see if this is happening for them, or has any idea how to fix this, I'd very much appreciate it.

Thanks,

Brian J. Soher
Duke University

middle_button_example2.py (3.13 KB)

···

-------------------------------------

import wxversion
wxversion.ensureMinimal('2.8')
from numpy import arange, sin, pi
import matplotlib

matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure
import wx

class CanvasFrame(wx.Frame):

     def __init__(self):
         wx.Frame.__init__(self,None,-1,'CanvasFrame',size=(550,350))
         self.SetBackgroundColour(wx.NamedColor("WHITE"))

         self.figure = Figure()
         self.axes = self.figure.add_subplot(111)
         t = arange(0.0,3.0,0.01)
         s = sin(2*pi*t)

         self.axes.plot(t,s)
         self.canvas = FigureCanvas(self, -1, self.figure)

         self.sizer = wx.BoxSizer(wx.VERTICAL)
         self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
         self.SetSizer(self.sizer)
         self.Fit()

         self.connect()

     def connect(self):
         'connect to all the events we need'
         self.cidpress = self.figure.canvas.mpl_connect('button_press_event', self.on_press)
         self.cidrelease = self.figure.canvas.mpl_connect('button_release_event', self.on_release)
         self.cidscroll = self.figure.canvas.mpl_connect('scroll_event', self.on_scroll)
         self.cidmotion = self.figure.canvas.mpl_connect('motion_notify_event', self.mouseMotion)
         self.cidkeydown = self.figure.canvas.mpl_connect('key_press_event', self.keyDown)
         self.cidkeyup = self.figure.canvas.mpl_connect('key_release_event', self.keyUp)

     def on_press(self, evt):
         print ' press evt.button = '+str(evt.button)
         if evt.button == 1:
             self.leftButtonDown(evt)
         elif evt.button == 2:
             self.middleButtonDown(evt)
         elif evt.button == 3:
             self.rightButtonDown(evt)

     def on_release(self, evt):
         if evt.button == 1:
             self.leftButtonUp(evt)
         elif evt.button == 2:
             print 'evt.button == 2'
             self.middleButtonUp(evt)
         elif evt.button == 3:
             self.rightButtonUp(evt)

     def on_scroll(self, evt):
         if evt.button == 'up':
             self.scrollUp(evt)
         elif evt.button == 'down':
             self.scrollDown(evt)

     def keyDown(self, evt):
         print ' keyDown()'

     def keyUp(self, evt):
         print ' keyUp()'

     def scrollDown(self, evt):
         print ' scrollDown()'

     def scrollUp(self, evt):
         print ' scrollUp()'

     def leftButtonDown(self, evt):
         print ' leftButtonDown()'

     def leftButtonUp(self, evt):
         print ' leftButtonUp()'

     def middleButtonDown(self, evt):
         print ' middleButtonDown()'

     def middleButtonUp(self, evt):
         print ' middleButtonUp()'

     def rightButtonDown(self, evt):
         print ' rightButtonDown()'

     def rightButtonUp(self, evt):
         print ' rightButtonUp()'

     def mouseMotion(self, evt):
         print ' mouseMotion()'

     def OnPaint(self, event):
         self.canvas.draw()

class App(wx.App):

     def OnInit(self):
         'Create the main window and insert the custom frame'
         frame = CanvasFrame()
         frame.Show(True)

         return True

app = App(0)
app.MainLoop()

From: Brian J. Soher [mailto:bsoher@…3323…]
Sent: Thursday, October 14, 2010 10:27

I'm using matplotlib 0.98.5.2, wxPython version 2.8-msw-unicode, on
Windows XP Professional x64 at work (and 32bit at home). At work I
have a plain old Dell 2 button mouse with a scroll wheel which you
can scroll or click as a middle mouse button. At home I have an
equivalent mouse from Logitec. Both mice exhibit useful
functionality for the "middle button" in browsers. And I did install
the latest Logitec drivers at home and specifically set the scroll
click to have the functionality of a middle mouse button.

In all cases, home or work, I failed to detect a middle mouse button
press or release event.

I've attached an example program and copied the text below.

If anyone could please check to see if this is happening for them, or
has any idea how to fix this, I'd very much appreciate it.

Hi, Brian. Your code reports left, middle, and right button events for me
with the same wx version but with matplotlib 1.0.0 on Windows 7 Pro x64. Do
you have the option of trying a more recent matplotlib?

Hi Stan,

Thank you for taking the time to check this for me. I did switch up to Matplotlib 1.0.0 and Python 2.6, and that solved my problem.

I'm tempted to chalk the whole thing up to having a corrupted Matplotlib installation, except that it did happen on two different computers.

All the best,

Brian.

···

At 12:22 PM 10/22/2010, Stan West wrote:

> From: Brian J. Soher [mailto:bsoher@…3323…]
> Sent: Thursday, October 14, 2010 10:27
>
> I'm using matplotlib 0.98.5.2, wxPython version 2.8-msw-unicode, on
> Windows XP Professional x64 at work (and 32bit at home). At work I
> have a plain old Dell 2 button mouse with a scroll wheel which you
> can scroll or click as a middle mouse button. At home I have an
> equivalent mouse from Logitec. Both mice exhibit useful
> functionality for the "middle button" in browsers. And I did install
> the latest Logitec drivers at home and specifically set the scroll
> click to have the functionality of a middle mouse button.
>
> In all cases, home or work, I failed to detect a middle mouse button
> press or release event.
>
> I've attached an example program and copied the text below.
>
> If anyone could please check to see if this is happening for them, or
> has any idea how to fix this, I'd very much appreciate it.

Hi, Brian. Your code reports left, middle, and right button events for me
with the same wx version but with matplotlib 1.0.0 on Windows 7 Pro x64. Do
you have the option of trying a more recent matplotlib?