Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3234322
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:22:40+00:00 2026-05-17T17:22:40+00:00

The following code demonstrates a problem with certain wx cursors on Windows (OSX cursors

  • 0

The following code demonstrates a problem with certain wx cursors on Windows (OSX cursors have a white outline)… namely, they are all black, and therefore completely invisible on a black background.

import wx
app = wx.PySimpleApp()
f = wx.Frame(None)
f.SetBackgroundColour(wx.Color(0))
f.SetCursor(wx.StockCursor(wx.CURSOR_CROSS))
f.Show()
app.MainLoop()

I wonder if anyone has found a way to patch the windows icons, or if there is a fix for it that I am unaware of.

The more specific problem I am having is that matplotlibs’ wx backend uses the wx.CURSOR_CROSS for zooming on imshow plots, which I am using to display images that are mostly black. I’ve yet to find a way to customize the cursors that mpl chooses, but I figured I’d pose the question while I dig.

Thanks,
Adam

Note: Using wxPython version 2.8.10.1 and matplotlib versions 0.99 and 1.0

PROGRESS:
I seem to be able to at least make my own cursor by doing the following, but I’m extremely frustrated to find that there is no way for me to include the color white anywhere. The documentation on this is horrendous.

import numpy as np
buf = np.ones((16,16,3), dtype='uint8') * 127   # pixels untouched by the following operations will outline the crosshair shape (wish they could be white)
buf[7,:,:] = 0        # horizontal black line
buf[:,7,:] = 0        # vertical black line
buf[:6,:6, :] = 255   # evidently values > 127 are interpreted as alpha
buf[9:,:6, :] = 255
buf[9:, 9:, :] = 255
buf[:6, 9:, :] = 255
im = wx.ImageFromBuffer(16, 16, buf.tostring()) # passing a separate alpha buffer just gets ignored
im.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 7)
im.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 7)
cursor = wx.CursorFromImage(im)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:22:41+00:00Added an answer on May 17, 2026 at 5:22 pm

    Welp, here’s what I came up with. Handling the mouse_enter and mouse_leave events isn’t good enough since the matplotlib navigation toolbar will set the cursor after the fact, so we need to set it on mouse motion.

    I wasn’t able to get a white outline around the crosshair icon, but I got close enough for now. so here it is.

    # Bind mouse motion events in the canvas
    self.figure.canvas.mpl_connect('motion_notify_event', self.on_mouse_move)
    
    # ...
    
    def on_mouse_move(self, evt):
        #
        # LAAAME SAUCE -- Crosshair cursor is all black on Windows making it
        #    virtually invisible on dark images. Use custom cursor instead.
        #
        if (sys.platform.lower().startswith('win') and 
            evt.inaxes and
            self.navtoolbar.mode == 'Zoom to rect mode'):  # NOTE: There are no constants for the navbar modes
            #
            # Build the crosshair cursor image as a numpy array.
            # Sadly I can't figure out how to make a white outline since every
            # value above 127 is apparently transparent.
            # Soooo the outline is yellow.
            #
            # Best docs I could find: http://wxruby.rubyforge.org/doc/cursor.html
            #
            buf = np.ones((16,16,3), dtype='uint8') * 255
            buf[:,:,2] = 1
            buf[7,1:-1,:] = buf[1:-1,7,:] = 0
            buf[:6,:6,:] = buf[9:,:6,:] = buf[9:,9:,:] = buf[:6,9:,:] = 255
            #
            # NOTE: I tried making an alpha channel and doing 
            #  wx.ImageFromBuffer(16, 16, buf.tostring(), alpha_buffer.to_string())
            # ...no good. wx just ignores the channel.
            #
            im = wx.ImageFromBuffer(16, 16, buf.tostring())
            im.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 7)
            im.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 7)
            cursor = wx.CursorFromImage(im)
            self.figure.canvas.SetCursor(cursor)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.