本文整理汇总了Python中matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg.unset_flags方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTKAgg.unset_flags方法的具体用法?Python FigureCanvasGTKAgg.unset_flags怎么用?Python FigureCanvasGTKAgg.unset_flags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg
的用法示例。
在下文中一共展示了FigureCanvasGTKAgg.unset_flags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PlotViewer
# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import unset_flags [as 别名]
class PlotViewer(gtk.VBox):
def __init__ (self, plotters, fields):
gtk.VBox.__init__ (self)
self.figure = mpl.figure.Figure ()
self.canvas = FigureCanvas (self.figure)
self.canvas.unset_flags (gtk.CAN_FOCUS)
self.canvas.set_size_request (600, 400)
self.pack_start (self.canvas, True, True)
self.canvas.show ()
self.navToolbar = NavigationToolbar (self.canvas, self.window)
#self.navToolbar.lastDir = '/tmp'
self.pack_start (self.navToolbar, False, False)
self.navToolbar.show ()
self.checkboxes = gtk.HBox (len (plotters))
self.pack_start (self.checkboxes, False, False)
self.checkboxes.show ()
self.pol = (1+0j, 0j)
self.pol2 = None
self.handlers = []
i = 0
self.plots = []
for plotterClass, default in plotters:
axes = self.figure.add_subplot (len (plotters), 1, i)
def makeUpdateInfo (i): return lambda s: self.__updateInfo (i, s)
def makeUpdatePos (i): return lambda s: self.__updatePos (i, s)
plotter = plotterClass (axes, fields, makeUpdateInfo (i), makeUpdatePos (i))
d = PlottedData (axes, plotter, default, self.__updateChildren)
self.checkboxes.pack_start (d.checkBox, False, False)
self.plots.append (d)
i += 1
self.__infos = [None] * len (self.plots)
self.__posi = None
self.legendBox = gtk.CheckButton ("Show legend")
self.legendBox.set_active (True)
self.legendBox.connect ("toggled", self.__on_legend_toggled)
self.checkboxes.pack_start (self.legendBox, False, False)
self.legendBox.show ()
self.__updateChildren ()
def __on_legend_toggled (self, button):
for pd in self.plots:
pd.plotter.setLegend (button.get_active ())
def __updateChildren (self):
count = 0
for axes in self.figure.get_axes ():
visible = axes.get_visible ()
if axes.get_visible ():
count += 1
if count == 0:
count = 1
nr = 1
for axes in self.figure.get_axes ():
axes.change_geometry (count, 1, nr)
if axes.get_visible ():
if nr < count:
nr += 1
else:
axes.set_position ((0, 0, 1e-10, 1e-10)) # Hack to prevent the invisible axes from getting mouse events
self.figure.canvas.draw ()
self.__updateGraph ()
def __updateGraph (self):
for pd in self.plots:
if pd.axes.get_visible ():
#start = time ()
pd.plotter.plot (self.pol, self.pol2)
#print "Plot ", pd.plotter.description, " needed ", time () - start
def __updateInfo (self, i, arg):
#print i, arg
self.__infos[i] = arg
s = ''
for info in self.__infos:
if info is not None:
if s != '':
s += ' '
s += info
for handler in self.handlers:
handler (s)
def __updatePos (self, i, arg):
if arg == None and self.__posi != i:
return
self.__posi = i
j = 0
for pd in self.plots:
if i != j:
pd.plotter.updateCPos (arg)
j += 1
def onUpdateInfo (self, handler):
#.........这里部分代码省略.........