Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to make a custom mouse cursor with Python Tkinter? (Using matplotlib with the TkAgg backend)
    text
    copied!<p>It's likely that this is just a general Python Tkinter question, not necessarily a matplotlib one.</p> <p>So I'm in the midst of developing a rather large suite of plotting functionality on top of matplotlib using the Matplotlib "TkAgg" backend (Agg rendering to a Tk canvas using TkInter). I'm using some of the default zooming functionality provided by matplotlib out of the box...specifically the "Zoom to box" button on the default matplotlib toolbar. I am creating my own toolbar by subclassing the existing "matplotlib.backends.backend_tkagg.NavigationToolbar2TkAgg" class.</p> <p>Pretty much, the issue here is that I hate the default icon that "Zoom to box" uses (the Tkinter "tcross"). I've figured out how to use a different Tkinter built-in cursor (e.g. this changes the cursor to "plus" instead of "tcross"):</p> <pre><code>import matplotlib matplotlib.use('TkAgg') import matplotlib.backend_bases import matplotlib.backends.backend_tk_agg matplotlib.backends.backend_tkagg.cursord[matplotlib.backend_bases.cursors.SELECT_REGION] = "plus" </code></pre> <p>And in general, I know that to change the current mouse cursor to one of the built-in Tkinter ones from the toolbar class, I can just call:</p> <pre><code>self.window.configure(cursor="cursor_name") </code></pre> <p>So what I would really, really like is to be able to use a magnifying glass icon for when the user is in "zoom mode". I already have a .ppm of the magnifying glass icon I'd like to use and everything, but I can't figure out for the life of me how to use my magnifying glass as the mouse cursor icon. Is it possible to use a custom image as a mouse cursor in Python Tkinter? Help!</p> <p><strong>Platform note</strong>: This needs to be workable on Mac OS X 10.5+, RedHat Enterprise Linux 5, and possibly Solaris 10, so a platform-specific solution is undesirable. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload