Module cmapmenu
source code
Defines CMapMenu, a wx submenu containing colormaps.
=== Example ===
The following defines a context menu with mapper:
import wx
import cmapmenu
...
def onContextMenu(self,event):
popup = wx.Menu()
item = popup.Append(wx.ID_ANY,'&Save image', 'Save image as PNG')
wx.EVT_MENU(self, item.GetId(), self.onSaveImage)
item = popup.Append(wx.ID_ANY,'&Grid on/off', 'Toggle grid lines')
wx.EVT_MENU(self, item.GetId(), self.onGridToggle)
item = popup.AppendMenu(wx.ID_ANY, "Colourmaps",
CMapMenu(self, self.mapper, self.canvas))
The assumption is that mapper and canvas are attributes of the panel for
which the context menu is defined. When the new colour map is selected,
the mapper will be reset and the figure redrawn.
Sometimes you will want to do more than just update the mapper for the
current canvas. You may for example want to record the new colormap name
in the application settings file so that it will be there when the
application is reloaded. To do this, call CMapMenu(callback=self.OnColormap).
This will call the method OnColormap with the parameter name giving the
name of the colormap.
|
|
CMapMenu
Menu tree binding to a list of colormaps.
|