Add “copy to clipboard” to the Toolbar

Wishlist: a “copy image to clipboard” button in the Toolbar for interactive backends.

For the wx backend, I’ve had some success with adding such a button by altering the function matplotlib.backends.NavigationToolbar2Wx._init_toolbar() in so that the last line:


is replaced by:

    _NTB2_COPY = wx.NewId()
    self.AddSimpleTool(_NTB2_COPY, _load_bitmap('stock_up.xpm'),
                        'Copy', 'Copy plot image to clipboard') 
    bind(self, wx.EVT_TOOL, self.copy, id=_NTB2_COPY) 


def copy(self, evt):
    self.canvas.Copy_to_Clipboard(event=evt) # bmp image

Author: Fantashit

1 thought on “Add “copy to clipboard” to the Toolbar

  1. If I may cast a vote, as a (former, at least for now) Matlab user I would also find this feature extremely useful.

    As of now I right click the toolbar of the Qt4 backend, uncheck the checkbox to hide the toolbar and use ksnapshot to grab a snapshot of the window region. Of course having a button would make everything faster 🙂

Comments are closed.