コード例 #1
0
ファイル: core.py プロジェクト: williamtang/scikit-image
def new_canvas(*args, **kwargs):
    """Return a new figure canvas."""
    allnums = _pylab_helpers.Gcf.figs.keys()
    num = max(allnums) + 1 if allnums else 1

    FigureClass = kwargs.pop('FigureClass', Figure)
    figure = FigureClass(*args, **kwargs)
    canvas = FigureCanvas(figure)
    fig_manager = FigureManagerQT(canvas, num)
    return fig_manager.canvas
コード例 #2
0
ファイル: traces.py プロジェクト: CamilleBo/pyHegel
 def __init__(self, width=9.00, height=7.00, dpi=72):
     self.fig = Figure(figsize=(width,height),dpi=dpi)
     self.canvas = TraceCanvas(self.fig)
     FigureManagerQT.__init__(self,self.canvas,-1)
     self.MainWidget = self.window
     self.setWindowTitle('Trace...')
     self.isclosed = False
     #########
     _figlist.append(self)
     # The closing of matplotlib was changed in 1.2.1
     #   https://github.com/matplotlib/matplotlib/pull/1498
     #   It used to have QtCore.Qt.WA_DeleteOnClose attribute set on the main window
     #   now it uses the closing signal for regular figures. Lets do something similar.
     #self.window.setAttribute(QtCore.Qt.WA_DeleteOnClose)
     # closing is emitted when calling function slot close (usually connected to the window close
     #  button)
     try:
         # for matplotlib >= 1.2.1
         self.window.closing.connect(self.close_slot)
     except AttributeError:
         # Using that QtCore.Qt.WA_DeleteOnClose attribute is set
         self.window.destroyed.connect(self.close_slot)