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


Python Button.disconnect方法代码示例

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


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

示例1: PickPhaseMenu

# 需要导入模块: from matplotlib.widgets import Button [as 别名]
# 或者: from matplotlib.widgets.Button import disconnect [as 别名]

#.........这里部分代码省略.........
		if not self.opts.xlimit is None:
			axpp.set_xlim(self.opts.xlimit)

	def labelSelection(self):
		""" Label selection status with transform (transAxes, transData).
		"""
		axpp = self.axpp
		trans = transforms.blended_transform_factory(axpp.transAxes, axpp.transData)
		colsel = self.opts.pppara.colorwave
		coldel = self.opts.pppara.colorwavedel
		axpp.annotate('Selected', xy=(1.015, self.azylim[0]), xycoords=trans, xytext=(1.03, -0.17),
			size=10, va='top', color=colsel,
			bbox=dict(boxstyle="round,pad=.2", fc='w', ec=(1,.5,.5)),  
			arrowprops=dict(arrowstyle="->",connectionstyle="angle,angleA=0,angleB=-90,rad=20",color=colsel, lw=2),)
		axpp.annotate('Deselected', xy=(1.015, self.azylim[1]), xycoords=trans, xytext=(1.03, 0.17),
			size=10, va='bottom', color=coldel,
			bbox=dict(boxstyle="round,pad=.2", fc='w', ec=(1,.5,.5)),  
			arrowprops=dict(arrowstyle="->",connectionstyle="angle,angleA=0,angleB=-90,rad=20",color=coldel, lw=2),)

	def getXLimit(self):
		""" Get x limit (relative to reference time) """
		pps = self.pps
		b = [ pp.time[0]  - pp.sacdh.reftime for pp in pps ]
		e = [ pp.time[-1] - pp.sacdh.reftime for pp in pps ]
		npts = [ len(pp.time) for pp in pps ]
		self.bmin = min(b) 
		self.bmax = max(b)
		self.emin = min(e) 
		self.emax = max(e)
		mm = self.bmin, self.emax
		xxlim = axLimit(mm)
		self.xzoom = [xxlim,]

	def getYLimit(self):
		""" Get y limit """
		saclist = self.gsac.saclist
		delta = saclist[0].delta
		data = array([ [min(sacdh.data), max(sacdh.data) ] for sacdh in saclist ])
		self.dmin = data[:,0].min()
		self.dmax = data[:,1].max() 

	def prev(self, event):
		self.replot(self.ipage-1)

	def next(self, event):
		self.replot(self.ipage+1)

	# return to the first page
	def fron(self, event):
		self.replot(0)

	def save(self, event):
		saveData(self.gsac, self.opts)

	def quit(self, event):
		self.finish()
		self.disconnect()
		close()

	def connect(self):
		self.axfron = self.axs['Fron']
		self.axprev = self.axs['Prev']
		self.axnext = self.axs['Next']
		self.axsave = self.axs['Save']
		self.axquit = self.axs['Quit']

		self.bnfron = Button(self.axfron, 'Fron')
		self.bnprev = Button(self.axprev, 'Prev')
		self.bnnext = Button(self.axnext, 'Next')
		self.bnsave = Button(self.axsave, 'Save')
		self.bnquit = Button(self.axquit, 'Quit')

		# call the function to execute on clicking the button
		self.cidfron = self.bnfron.on_clicked(self.fron)
		self.cidprev = self.bnprev.on_clicked(self.prev)
		self.cidnext = self.bnnext.on_clicked(self.next)
		self.cidsave = self.bnsave.on_clicked(self.save)
		self.cidquit = self.bnquit.on_clicked(self.quit)

		self.cidpress = self.axpp.figure.canvas.mpl_connect('key_press_event', self.on_zoom)

	def disconnect(self):
		self.bnfron.disconnect(self.cidfron)
		self.bnprev.disconnect(self.cidprev)
		self.bnnext.disconnect(self.cidnext)
		self.bnsave.disconnect(self.cidsave)
		self.bnquit.disconnect(self.cidquit)

		self.axfron.cla()
		self.axprev.cla()
		self.axnext.cla()
		self.axsave.cla()
		self.axquit.cla()

		self.axpp.figure.canvas.mpl_disconnect(self.cidpress)
		self.span.visible = False

	def finish(self):
		for pp in self.pps:	pp.disconnect()
		self.axpp.cla()
开发者ID:ehparker,项目名称:pysmo,代码行数:104,代码来源:pickphase.py

示例2: PickPhaseMenu

# 需要导入模块: from matplotlib.widgets import Button [as 别名]
# 或者: from matplotlib.widgets.Button import disconnect [as 别名]

#.........这里部分代码省略.........
	"""save headers and override data with filtered data
	   @lowFreq -> user0
	   @highFreq -> user1
	   @band -> kuser0
	   @order -> kuser1, need to convert to integer form alphanumeric
	"""
	def shfp(self, event):
		# write params to file
		for sacdh in self.gsac.saclist: 
			sacdh.user0 = self.opts.filterParameters['lowFreq']
			sacdh.user1 = self.opts.filterParameters['highFreq']
			sacdh.kuser0 = self.opts.filterParameters['band']
			sacdh.kuser1 = self.opts.filterParameters['order']
		if 'stkdh' in self.gsac.__dict__:
			self.gsac.stkdh.user0 = self.opts.filterParameters['lowFreq']
			self.gsac.stkdh.user1 = self.opts.filterParameters['highFreq']
			self.gsac.stkdh.kuser0 = self.opts.filterParameters['band']
			self.gsac.stkdh.kuser1 = self.opts.filterParameters['order']

		# save
		saveData(self.gsac, self.opts)

	"""save headers and override"""
	def shod(self, event):
		shouldRun = messagebox.askokcancel("Will Override Files!","This will override the data in your files with the filtered data. \nAre you sure?")
		if shouldRun: 
			for sacdh in self.gsac.saclist: 
				sacdh.data = ftr.filtering_time_signal(sacdh.data, self.opts.delta, self.opts.filterParameters['lowFreq'], self.opts.filterParameters['highFreq'], self.opts.filterParameters['band'], self.opts.filterParameters['order'])
			if 'stkdh' in self.gsac.__dict__:
				self.gsac.stkdh.data = ftr.filtering_time_signal(self.gsac.stkdh.data, self.opts.delta, self.opts.filterParameters['lowFreq'], self.opts.filterParameters['highFreq'], self.opts.filterParameters['band'], self.opts.filterParameters['order'])
			saveData(self.gsac, self.opts)


	# ---------------------------- SAVE HEADERS FILES ------------------------------- #

	def quit(self, event):
		self.finish()
		self.disconnect(event.canvas)
		plt.close('all')

	def connect(self):
		self.axfron = self.axs['Fron']
		self.axprev = self.axs['Prev']
		self.axnext = self.axs['Next']
		self.axlast = self.axs['Last']
		self.axzoba = self.axs['Zoba']
		self.axshdo = self.axs['Shdo']
		self.axshfp = self.axs['Shfp']
		self.axshod = self.axs['Shod']
		self.axquit = self.axs['Quit']

		self.bnfron = Button(self.axfron, 'Front')
		self.bnprev = Button(self.axprev, 'Prev')
		self.bnnext = Button(self.axnext, 'Next')
		self.bnlast = Button(self.axlast, 'Last')
		self.bnzoba = Button(self.axzoba, 'Zoom \n Back')
		self.bnshdo = Button(self.axshdo, 'Save')
		self.bnshfp = Button(self.axshfp, 'Save \n Params')
		self.bnshod = Button(self.axshod, 'Save \n Override')
		self.bnquit = Button(self.axquit, 'Quit')

		self.cidfron = self.bnfron.on_clicked(self.fron)
		self.cidprev = self.bnprev.on_clicked(self.prev)
		self.cidnext = self.bnnext.on_clicked(self.next)
		self.cidlast = self.bnlast.on_clicked(self.last)
		self.cidzoba = self.bnzoba.on_clicked(self.zoba)
		self.cidshdo = self.bnshdo.on_clicked(self.shdo)
		self.cidshfp = self.bnshfp.on_clicked(self.shfp)
		self.cidshod = self.bnshod.on_clicked(self.shod)
		self.cidquit = self.bnquit.on_clicked(self.quit)

		self.cidpress = self.axpp.figure.canvas.mpl_connect('key_press_event', self.on_zoom)

	def disconnect(self, canvas):
		self.bnfron.disconnect(self.cidfron)
		self.bnprev.disconnect(self.cidprev)
		self.bnnext.disconnect(self.cidnext)
		self.bnlast.disconnect(self.cidlast)
		self.bnzoba.disconnect(self.cidzoba)
		self.bnshdo.disconnect(self.cidshdo)
		self.bnshfp.disconnect(self.cidshfp)
		self.bnshod.disconnect(self.cidshod)

		self.axfron.cla()
		self.axprev.cla()
		self.axnext.cla()
		self.axlast.cla()
		self.axzoba.cla()
		self.axshdo.cla()
		self.axshfp.cla()
		self.axshod.cla()
		self.axquit.cla()

		canvas.mpl_disconnect(self.cidpress)
		self.span.visible = False

	def finish(self):
		for pp in self.pps:	
			pp.disconnect()
		self.axpp.cla()
开发者ID:xlougeo,项目名称:aimbat,代码行数:104,代码来源:pickphase.py

示例3: __init__

# 需要导入模块: from matplotlib.widgets import Button [as 别名]
# 或者: from matplotlib.widgets.Button import disconnect [as 别名]
class PickPhaseMenuMore:
	""" Pick phase for multiple seismograms and array stack
		Button: Sync
	"""
	def __init__(self, gsac, opts, axs):
		self.gsac = gsac
		self.opts = opts
		self.axs = axs
		self.axstk = self.axs['Fstk']
		if not 'stkdh' in gsac.__dict__:
			if opts.filemode == 'sac' and os.path.isfile(opts.fstack):
				gsac.stkdh = SacDataHdrs(opts.fstack, opts.delta)
			else:
				hdrini, hdrmed, hdrfin = opts.qcpara.ichdrs
				self.cchdrs = [hdrini, hdrmed]
				self.twcorr = opts.ccpara.twcorr
				# check data coverage
				opts.ipick = hdrini
				opts.twcorr = opts.ccpara.twcorr
				checkCoverage(gsac, opts) 
				gsac.selist = gsac.saclist
				self.ccStack()
		self.initPlot()
		self.plotStack()
		self.setLabels()
		self.connect()

	def initPlot(self):
		""" Plot waveforms """
		gsac = self.gsac
		opts = self.opts
		sortSeis(gsac, opts)
		self.ppm = PickPhaseMenu(gsac, opts, self.axs)
		# make the legend box invisible
		if self.opts.pick_on:
			self.ppm.axpp.get_legend().set_visible(False)

	def setLabels(self):
		""" Set plot attributes """
		self.ppm.axpp.set_title('Seismograms')
		if self.opts.filemode == 'pkl':
			axstk = self.axstk
			trans = transforms.blended_transform_factory(axstk.transAxes, axstk.transAxes)
			axstk.text(1,1.01,self.opts.pklfile,transform=trans, va='bottom', ha='right',color='k')
		axpp = self.ppm.axpp
		trans = transforms.blended_transform_factory(axpp.transAxes, axpp.transData)
		font = FontProperties()
		font.set_family('monospace')
		axpp.text(1.025, 0, ' '*8+'qual= CCC/SNR/COH', transform=trans, va='center', 
			color='k', fontproperties=font)

	def plotStack(self):
		""" Plot array stack and span """
		colorwave = self.opts.pppara.colorwave
		stkybase = 0
		ppstk = PickPhase(self.gsac.stkdh, self.opts,self.axstk, stkybase, colorwave, 1) 
		ppstk.plotPicks()
		ppstk.disconnectPick()
		self.ppstk = ppstk
		self.axstk.set_title('Array Stack')
		self.ppstk.stalabel.set_visible(False)
		if self.opts.ynorm == 1.0:
			self.axstk.set_ylim(stkybase-0.5, stkybase+0.5)
		self.axstk.set_yticks([stkybase])
		self.axstk.set_yticklabels([])
		self.axstk.axvline(x=0, color='k', ls=':')
		# plot legend
		pppara = self.opts.pppara
		pickLegend(self.axstk, pppara.npick, pppara.pickcolors, pppara.pickstyles, False)
		self.plotSpan()

	def plotSpan(self):
		""" Span for array stack """
		axstk = self.axstk
		self.xzoom = [axstk.get_xlim(),]
		def on_select(xmin, xmax):
			""" Mouse event: select span. """
			if self.span.visible:
				print 'span selected: %6.1f %6.1f ' % (xmin, xmax)
				xxlim = (xmin, xmax)
				axstk.set_xlim(xxlim)
				self.xzoom.append(xxlim)
				if self.opts.upylim_on:
					print ('upylim')
					ppstk.updateY(xxlim)
				axstk.figure.canvas.draw()
		pppara = self.opts.pppara
		a, col = pppara.alphatwsele, pppara.colortwsele
		mspan = pppara.minspan * self.opts.delta
		self.span = TimeSelector(axstk, on_select, 'horizontal', minspan=mspan, useblit=False,
			rectprops=dict(alpha=a, facecolor=col))

	def on_zoom(self, event):
		""" Zoom back to previous xlim when event is in event.inaxes.
		"""
		evkey = event.key
		axstk = self.axstk
		if not axstk.contains(event)[0] or evkey is None: return
		xzoom = self.xzoom
		if evkey.lower() == 'z' and len(xzoom) > 1:
#.........这里部分代码省略.........
开发者ID:ehparker,项目名称:pysmo,代码行数:103,代码来源:qualctrl.py


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