Missing Toolbar Button inside Wx Application

Hi all,

if I plot an normal figure the toolbar contains an button (looks like a checkbox), which can be used to edit the lines and axes parameters. But when I embed such a figure in an Wx application, this specfic button is missing.

Is there a way around it?

Thanks for your help,

Sebi

Parts of the Code:

import wx

import os

import numpy as np

import wx.grid

import filtertools as ft

Matplotlib Figure object

from matplotlib.figure import Figure

import the WxAgg FigureCanvas object, that binds Figure to

WxAgg backend --> a wxPanel

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas

import the NavigationToolbar WxAgg widget

from matplotlib.backends.backend_wx import NavigationToolbar2Wx


class MplPanel(wx.Panel):

def init(self, *args, **kwds):

wx.Panel.init(self, *args, **kwds)

self.__set_properties()

self.__do_layout()

self.figure = Figure(figsize=(sizex, sizey), dpi=res)

self.axes = self.figure.add_subplot(111)

self.axes.set_xticks(np.arange(self.xmin_limit, self.xmax_limit, 20))

self.axes.set_yticks(np.arange(self.ymin, self.ymax, 0.1));

self.axes.axis([self.xmin,self.xmax,self.ymin,self.ymax])

self.axes.grid(True)

self.axes.set_xlabel(‘Wavelength [nm]’,fontsize=14)

self.axes.set_ylabel(‘Transmission [%] or Intensity [a.u.]’,fontsize=14)

self.figure.subplots_adjust(left=0.07, bottom=0.09, right=0.97, top=0.94,wspace=0.20, hspace=0.20)

self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)

self.sizer = wx.BoxSizer(wx.VERTICAL)

self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)

self.toolbar = NavigationToolbar2Wx(self.canvas)

self.toolbar.Realize()

self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)

self.toolbar.Show()

self.SetSizer(self.sizer)

self.Fit()

···


Dr. Sebastian Rhode
Grünwalder Str. 103a
81547 München
Tel: +49 89 4703091
Mobil: +49 15122810945
sebrhode@…982…

From: Sebastian Rhode [mailto:sebrhode@…982…]
Sent: Wednesday, September 29, 2010 13:02

if I plot an normal figure the toolbar contains an button (looks like a checkbox), which can be used to edit the lines and axes parameters. But when I embed such a figure in an Wx application, this specfic button is missing.

Is there a way around it?

That tool is implemented in the Qt4 backends (and in only those backends, I believe). If your default backend is Qt4Agg, for example, you would see the tool when not embedding. For embedding with Wx, you would need the tool implemented in backend_wx.py, class NavigationToolbar2Wx. Should you like to look at the Qt4 code, it’s in backend_qt4.py, class NavigationToolbar2QT.