本文整理汇总了Python中matplotlib.backends.backend_qt5agg.NavigationToolbar2QT._icon方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT._icon方法的具体用法?Python NavigationToolbar2QT._icon怎么用?Python NavigationToolbar2QT._icon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt5agg.NavigationToolbar2QT
的用法示例。
在下文中一共展示了NavigationToolbar2QT._icon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MplWidget
# 需要导入模块: from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.NavigationToolbar2QT import _icon [as 别名]
class MplWidget(QtWidgets.QWidget):
"""
Widget defined in Qt Designer.
"""
zoom_to_full_view = pyqtSignal()
map_press = pyqtSignal(float, float)
def __init__(self, parent = None):
# initialization of Qt MainWindow widget
QtWidgets.QWidget.__init__(self, parent)
# set the canvas to the Matplotlib widget
self.canvas = MplCanvas()
self.ntb = NavigationToolbar(self.canvas, self)
#self.ntb.removeAction(self.ntb.buttons[0])
self.ntb.clear()
program_folder = os.path.join(os.path.dirname(__file__), "ims")
a = self.ntb.addAction(self.ntb._icon(os.path.join(program_folder, "world.png")), 'Home', self.zoom2fullextent)
a.setToolTip('Reset original view')
a = self.ntb.addAction(self.ntb._icon(os.path.join(program_folder, "arrow_left.png")), 'Back', self.ntb.back)
a.setToolTip('Back to previous view')
a = self.ntb.addAction(self.ntb._icon(os.path.join(program_folder, "arrow_right.png")), 'Forward', self.ntb.forward)
a.setToolTip('Forward to next view')
a = self.ntb.addAction(self.ntb._icon(os.path.join(program_folder, "arrow_out.png")), 'Pan', self.ntb.pan)
a.setToolTip('Pan axes with left mouse, zoom with right')
a = self.ntb.addAction(self.ntb._icon(os.path.join(program_folder, "zoom.png")), 'Zoom', self.ntb.zoom)
a.setToolTip('Zoom to rectangle')
action_SetSrcPt = self.ntb.addAction(self.ntb._icon(os.path.join(program_folder, "bullet_red.png")), 'Source point', self.pt_map)
action_SetSrcPt.setToolTip('Set source point in map')
a = self.ntb.addAction(self.ntb._icon(os.path.join(program_folder, "camera.png")), 'Save',
self.ntb.save_figure)
a.setToolTip('Save map as image')
a = self.ntb.addAction(self.ntb._icon(os.path.join(program_folder, "help.png")), 'Help',
self.openHelp)
a.setToolTip('Help')
a = self.ntb.addAction(self.ntb._icon(os.path.join(program_folder, "information.png")), 'About',
self.helpAbout)
a.setToolTip('About')
# create a vertical box layout
self.vbl = QtWidgets.QVBoxLayout()
# add widgets to the vertical box
self.vbl.addWidget(self.canvas)
self.vbl.addWidget(self.ntb)
# set the layout to the vertical box
self.setLayout(self.vbl)
def onclick(self, event):
"""
Emit a signal to induce the update of source point location.
@param event: press event.
@type event: Matplotlib event.
"""
global set_srcpt_count, cid
set_srcpt_count += 1
if set_srcpt_count == 1:
self.map_press.emit(event.xdata, event.ydata)
self.canvas.fig.canvas.mpl_disconnect(cid)
def pt_map(self):
"""
Connect the press event with the function for updating the source point location.
"""
global set_srcpt_count, cid
set_srcpt_count = 0
cid = self.canvas.fig.canvas.mpl_connect('button_press_event', self.onclick)
def zoom2fullextent(self):
"""
Emit the signal for updating the map view to the extent of the DEM, in alternative of
the shapefile, or at the standard extent.
"""
self.zoom_to_full_view.emit()
def openHelp(self):
"""
Open an Help HTML file
after CADTOOLS module in QG
#.........这里部分代码省略.........