Restrict an invisible mouse cursor to an OpenGL canvas within a frame

I would like to be able to make the mouse cursor temporarily invisible when the mouse is in an OpenGL canvas within a frame. I know how to make the cursor invisible over the entire frame as shown below (where self.win is the frame in this code), so my question is how to arrange that the the cursor remains visible in a restricted region of the frame.

        if 'phoenix' in _wx.PlatformInfo:
            self.win.SetCursor(_wx.Cursor(_wx.CURSOR_BLANK)) # Phoenix
        else:
            self.win.SetCursor(_wx.StockCursor(_wx.CURSOR_BLANK)) # Classic

I've never used OpenGL canvas, but from these docs:

http://wxpython.org/Phoenix/docs/html/glcanvas.GLCanvas.html

....it shows that the canvas inherits from wxWindow, so the method you
could use is the mouseevent, wxEVT_ENTER_WINDOW. I guess you would bind
your canvas object, something like:

self.canvas.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterCanvas)

def OnEnterCanvas(self,event):
    # and then here just put that code you have above.

Though I have not tried this with this particular widget (but have used
that event in other situations).

Che

···

On Sun, Apr 27, 2014 at 9:11 PM, Bruce Sherwood <bruce.sherwood@gmail.com>wrote:

I would like to be able to make the mouse cursor temporarily invisible
when the mouse is in an OpenGL canvas within a frame. I know how to make
the cursor invisible over the entire frame as shown below (where self.win
is the frame in this code), so my question is how to arrange that the the
cursor remains visible in a restricted region of the frame.

            if 'phoenix' in _wx.PlatformInfo:
                self.win.SetCursor(_wx.Cursor(_wx.CURSOR_BLANK)) # Phoenix
            else:
                self.win.SetCursor(_wx.StockCursor(_wx.CURSOR_BLANK)) #
Classic

Thanks. It had occurred to me that I could do something like that but had naively hoped that I could just define the mouse cursor to be invisible when in the canvas rectangle, rather than doing the watching myself.

I don't know that you can't do that; maybe you can. What would be the
advantage over this method?

···

On Mon, Apr 28, 2014 at 1:02 AM, Bruce Sherwood <bruce.sherwood@gmail.com>wrote:

Thanks. It had occurred to me that I could do something like that but had
naively hoped that I could just define the mouse cursor to be invisible
when in the canvas rectangle, rather than doing the watching myself.

No real advantage I guess – just laziness.

Thanks. It had occurred to me that I could do something like that but had
naively hoped that I could just define the mouse cursor to be invisible
when in the canvas rectangle, rather than doing the watching myself.

Have you tried calling SetCursor on the GLCanvas itself? It's a wx.Window

method, I think it should work.

-CHB

···

On Sun, Apr 27, 2014 at 10:02 PM, Bruce Sherwood <bruce.sherwood@gmail.com>wrote:

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Thanks, Chris. That does indeed work fine and does just what I want.

Bruce

I learned something, too. That is simpler and better, thanks also Chris.

···

On Mon, Apr 28, 2014 at 4:23 PM, Bruce Sherwood <bruce.sherwood@gmail.com>wrote:

Thanks, Chris. That does indeed work fine and does just what I want.