當前位置: 首頁>>代碼示例>>Python>>正文


Python NavigationToolbar2QT.setIconSize方法代碼示例

本文整理匯總了Python中matplotlib.backends.backend_qt4.NavigationToolbar2QT.setIconSize方法的典型用法代碼示例。如果您正苦於以下問題:Python NavigationToolbar2QT.setIconSize方法的具體用法?Python NavigationToolbar2QT.setIconSize怎麽用?Python NavigationToolbar2QT.setIconSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.backends.backend_qt4.NavigationToolbar2QT的用法示例。


在下文中一共展示了NavigationToolbar2QT.setIconSize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: MPL_Widget

# 需要導入模塊: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 別名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import setIconSize [as 別名]
class MPL_Widget(QtGui.QWidget):
    def __init__(self, parent = None, enableAutoScale = False, enableCSV = False, enableEdit = False, doublePlot = False, layoutDir = 'h'):
        QtGui.QWidget.__init__(self, parent)
        if doublePlot:
            self.canvas = DoubleMyMplCanvas()
        else:
            self.canvas = MyMplCanvas()
        self.toolbar = NavigationToolbar(self.canvas, self.canvas)
        self.iconSize = QtCore.QSize(15,15)
        self.toolbar.setIconSize(self.iconSize)

        self.installEventFilter(EventFilter(self))

        if layoutDir == 'v':
            self.toolbar.setOrientation(QtCore.Qt.Vertical)
            self.layout = QtGui.QHBoxLayout()


        elif layoutDir == 'h':
            self.layout = QtGui.QVBoxLayout()
#            self.layout.addWidget(self.canvas)
#            self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.canvas)
        self.setLayout(self.layout)

        ###############ZOOM CONTROLS ################




        #This function has been disabled because of the special autoscaling requried for a custom program
        #FIX THIS
        if enableAutoScale:
            print "Enable AutoScale"
            #self.enableAutoScale()


        self.span = SpanSelector(self.canvas.ax, self.onselect, 'horizontal', minspan =0.01,
                                 useblit=True, rectprops=dict(alpha=0.5, facecolor='#C6DEFF') )
        self.hZoom = False
        self.span.visible = False

        self.localYMax = 0
        self.canvas.mpl_connect('button_press_event', self.onclick)

        ###########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')

#        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)

        if enableEdit:
            self.enableEdit()

        self.lineDict = None
        self.addLegend = False


        #######SAVING FIGURE DATA############################
        if enableCSV:
            self.enableCSV()


        ########### HELPER FUNCTIONS #########################
#    def focusOutEvent(self, event):
#        print "Focus Out"

    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)

    def enableEdit(self):
        self.editAction = QtGui.QAction("Edit Line Properties",  self)
        self.editAction.setShortcut("Ctrl+Alt+E")
        self.addAction(self.editAction)
#.........這裏部分代碼省略.........
開發者ID:pombredanne,項目名稱:toolz-1,代碼行數:103,代碼來源:mpl_pyqt4_widget.py


注:本文中的matplotlib.backends.backend_qt4.NavigationToolbar2QT.setIconSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。