当前位置: 首页>>代码示例>>Python>>正文


Python NavigationToolbar2QT.hide方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_qt4.NavigationToolbar2QT.hide方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT.hide方法的具体用法?Python NavigationToolbar2QT.hide怎么用?Python NavigationToolbar2QT.hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_qt4.NavigationToolbar2QT的用法示例。


在下文中一共展示了NavigationToolbar2QT.hide方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MPL_Widget

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import hide [as 别名]
class MPL_Widget(QtGui.QWidget):
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.canvas = MyMplCanvas()
        #self.toolbar = MyNavigationToolbar(self.canvas, self.canvas, direction = 'v')
        self.toolbar = NavigationToolbar(self.canvas, self.canvas)
        self.toolbar.hide()
        self.hbox = QtGui.QHBoxLayout()
        #self.hbox.addWidget(self.toolbar)
        self.hbox.addWidget(self.canvas)
        self.setLayout(self.hbox)
        ##########################
        self.hZoom = QtGui.QAction("Zoom",  self)
        self.hZoom.setShortcut("Ctrl+Z")
        self.addAction(self.hZoom)
        QtCore.QObject.connect(self.hZoom,QtCore.SIGNAL("triggered()"), self.ZoomToggle)

        self.actionAutoScale = QtGui.QAction("AutoScale",  self)#self.MainWindow)
        self.actionAutoScale.setShortcut("Ctrl+A")
        self.addAction(self.actionAutoScale)
        QtCore.QObject.connect(self.actionAutoScale,QtCore.SIGNAL("triggered()"), self.autoscale_plot)


        self.installEventFilter(EventFilter(self))

        ###########SAVING FIGURE TO CLIPBOARD##########
        self.cb = None #will be used for the clipboard
        self.tempPath = getHomeDir()
        self.tempPath = os.path.join(self.tempPath,'tempMPL.png')

    def ZoomToggle(self):
        self.toolbar.zoom()

    def autoscale_plot(self):
        self.toolbar.home()

    def mpl2Clip(self):
        try:
            self.canvas.fig.savefig(self.tempPath)
            tempImg = QtGui.QImage(self.tempPath)
            self.cb = QtGui.QApplication.clipboard()
            self.cb.setImage(tempImg)
        except:
            print 'Error copying figure to clipboard'
            errorMsg = "Sorry: %s\n\n:%s\n"%(sys.exc_type, sys.exc_value)
            print errorMsg

    def focusEvent(self, event):
#        self.enableAutoScale()
#        self.enableZoom()
        self.enableClip()
#        self.enableCSV()
        #print "Focus In %s"%self.canvas.plotTitle

    def lossFocusEvent(self, event):
#        self.disableAutoScale()
#        self.disableZoom()
        self.disableClip()
#        self.disableCSV()
        #print "Focus Out %s"%self.canvas.plotTitle

    def enableClip(self):
        self.mpl2ClipAction = QtGui.QAction("Save to Clipboard",  self)
        self.mpl2ClipAction.setShortcut("Ctrl+C")
        self.addAction(self.mpl2ClipAction)
        QtCore.QObject.connect(self.mpl2ClipAction,QtCore.SIGNAL("triggered()"), self.mpl2Clip)

    def disableClip(self):
        QtCore.QObject.disconnect(self.mpl2ClipAction,QtCore.SIGNAL("triggered()"), self.mpl2Clip)
        self.removeAction(self.mpl2ClipAction)
开发者ID:pombredanne,项目名称:toolz-1,代码行数:72,代码来源:mplElemIso.py


注:本文中的matplotlib.backends.backend_qt4.NavigationToolbar2QT.hide方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。