本文整理汇总了Python中matplotlib.backends.backend_qt4agg.NavigationToolbar2QT._icon方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT._icon方法的具体用法?Python NavigationToolbar2QT._icon怎么用?Python NavigationToolbar2QT._icon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.NavigationToolbar2QT
的用法示例。
在下文中一共展示了NavigationToolbar2QT._icon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyWeramiWindow
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import _icon [as 别名]
class PyWeramiWindow(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self, filename=None, parent=None):
super(PyWeramiWindow,self).__init__(parent)
self.settings = QtCore.QSettings("LX", "pywerami")
self.setupUi(self)
self._fig = plt.figure(facecolor="white")
self._ax = self._fig.add_subplot(111)
self._canvas = FigureCanvas(self._fig)
self._canvas.setParent(self.widget)
self._canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
self.matplot.addWidget(self._canvas)
self.mpl_toolbar = NavigationToolbar(self._canvas,self.widget)
self.mpl_toolbar.hide()
self.matplot.addWidget(self.mpl_toolbar)
#set combos
self.cmaps = [m for m in plt.cm.datad if not m.endswith("_r")]
self.mapstyle.addItems(self.cmaps)
# set validators
self.levelmin.setValidator(QtGui.QDoubleValidator(self.levelmin))
self.levelmax.setValidator(QtGui.QDoubleValidator(self.levelmax))
self.levelnum.setValidator(QtGui.QIntValidator(self.levelmin))
self.levelstep.setValidator(QtGui.QDoubleValidator(self.levelstep))
self.clipmin.setValidator(QtGui.QDoubleValidator(self.clipmin))
self.clipmax.setValidator(QtGui.QDoubleValidator(self.clipmax))
# Set icons in toolbar
self.actionOpen.setIcon(QtGui.QIcon.fromTheme('document-open'))
self.actionSave.setIcon(QtGui.QIcon.fromTheme('document-save'))
self.actionSaveas.setIcon(QtGui.QIcon.fromTheme('document-save-as'))
self.actionImport.setIcon(QtGui.QIcon.fromTheme('x-office-spreadsheet'))
self.actionHome.setIcon(self.mpl_toolbar._icon('home.png'))
self.actionPan.setIcon(self.mpl_toolbar._icon('move.png'))
self.actionZoom.setIcon(self.mpl_toolbar._icon('zoom_to_rect.png'))
self.actionGrid.setIcon(QtGui.QIcon.fromTheme('format-justify-fill'))
self.actionAxes.setIcon(self.mpl_toolbar._icon('qt4_editor_options.png'))
self.actionSavefig.setIcon(self.mpl_toolbar._icon('filesave.png'))
#self.action3D.setIcon(QtGui.QIcon.fromTheme(''))
self.actionProperties.setIcon(QtGui.QIcon.fromTheme('preferences-other'))
self.actionQuit.setIcon(QtGui.QIcon.fromTheme('application-exit'))
self.actionAbout.setIcon(QtGui.QIcon.fromTheme('help-about'))
self.actionImport.triggered.connect(self.import_data)
self.actionHome.triggered.connect(self.mpl_toolbar.home)
self.actionPan.triggered.connect(self.plotpan)
self.actionZoom.triggered.connect(self.plotzoom)
self.actionGrid.triggered.connect(self.plotgrid)
self.actionAxes.triggered.connect(self.mpl_toolbar.edit_parameters)
self.actionSavefig.triggered.connect(self.mpl_toolbar.save_figure)
self.actionProperties.triggered.connect(self.edit_options)
self.actionQuit.triggered.connect(self.close)
if filename:
self.import_data(filename)
# ready
self.statusbar.showMessage("Ready", 5000)
def closeEvent(self,event):
reply=QtGui.QMessageBox.question(self,'Message',"Are you sure to quit?",QtGui.QMessageBox.Yes,QtGui.QMessageBox.No)
if reply==QtGui.QMessageBox.Yes:
event.accept()
else:
event.ignore()
def import_data(self, filename=None):
if not filename:
filename = QtGui.QFileDialog.getOpenFileName(self, "Import tab file", ".", "TAB (*.tab);;All files (*.*)")
if filename:
self.data = WeramiData.from_tab(filename)
# populate listview and setup properties
self.props = {}
self._model = QtGui.QStandardItemModel(self.listView)
for var in self.data.dep:
item = QtGui.QStandardItem(var)
item.setCheckable(True)
self._model.appendRow(item)
self.default_var_props(var)
self.listView.setModel(self._model)
self.listView.show()
# connect listview signals
self.varSel = self.listView.selectionModel()
self.varSel.selectionChanged.connect(self.on_var_changed)
self._model.itemChanged.connect(self.plot)
# buttons signals
self.buttonBox.button(QtGui.QDialogButtonBox.Apply).clicked.connect(self.apply_props)
self.buttonBox.button(QtGui.QDialogButtonBox.RestoreDefaults).clicked.connect(self.restore_props)
self.contcolor.clicked.connect(self.contours_color)
self.action3D.triggered.connect(self.switch3d)
# signals to calculate step size
self.levelmin.editingFinished.connect(self.step_from_levels)
self.levelmax.editingFinished.connect(self.step_from_levels)
self.levelnum.editingFinished.connect(self.step_from_levels)
self.setlevels.toggled.connect(self.step_from_levels)
# all done focus
#.........这里部分代码省略.........
示例2: _icon
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import _icon [as 别名]
def _icon(self, name):
if name.startswith(os.path.sep):
return QtGui.QIcon(name)
return NavigationToolbar._icon(self, name)