本文整理汇总了Python中matplotlib.backends.backend_tkagg.FigureCanvasTkAgg.find_all方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasTkAgg.find_all方法的具体用法?Python FigureCanvasTkAgg.find_all怎么用?Python FigureCanvasTkAgg.find_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_tkagg.FigureCanvasTkAgg
的用法示例。
在下文中一共展示了FigureCanvasTkAgg.find_all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wishbone_gui
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import find_all [as 别名]
#.........这里部分代码省略.........
self.geneSelectBox = tk.Listbox(self.geneSelection, selectmode=tk.EXTENDED)
self.geneSelectBox.grid(row=2, rowspan=10)
self.geneSelectBox.bind('<BackSpace>', self.DeleteSelected)
self.selectedGenes = []
tk.Button(self.geneSelection, text="Use selected genes", command=self.geneSelection.destroy).grid(row=12)
tk.Button(self.geneSelection, text="Cancel", command=self.cancelGeneSelection).grid(row=13)
self.wait_window(self.geneSelection)
def cancelGeneSelection(self):
self.selectedGenes = []
self.geneSelection.destroy()
def AddToSelected(self, event):
self.selectedGenes.append(self.geneInput.get())
self.geneSelectBox.insert(tk.END, self.selectedGenes[len(self.selectedGenes)-1])
def DeleteSelected(self, event):
selected = self.geneSelectBox.curselection()
pos = 0
for i in selected:
idx = int(i) - pos
self.geneSelectBox.delete( idx,idx )
self.selectedGenes = self.selectedGenes[:idx] + self.selectedGenes[idx+1:]
pos = pos + 1
def savePlot(self):
self.plotFileName = filedialog.asksaveasfilename(title='Save Plot', defaultextension='.png', initialfile=self.fileNameEntryVar.get()+"_"+self.currentPlot)
if self.plotFileName != None:
self.fig.savefig(self.plotFileName)
def setGate(self):
#pop up for gate name
self.gateOptions = tk.Toplevel()
self.gateOptions.title("Create gate for start cells")
tk.Label(self.gateOptions,text=u"Gate name:" ,fg="black",bg="white").grid(column=0, row=0)
self.gateName = tk.StringVar()
self.gateName.set('Gate ' + str(len(self.gates) + 1))
tk.Entry(self.gateOptions, textvariable=self.gateName).grid(column=1,row=0)
tk.Button(self.gateOptions, text="Select gate", command=self._setGate).grid(column=1, row=1)
tk.Button(self.gateOptions, text="Cancel", command=self.gateOptions.destroy).grid(column=0, row=1)
self.wait_window(self.gateOptions)
def _setGate(self):
self.gateOptions.destroy()
self.buttonPress = self.canvas.mpl_connect('button_press_event', self._startGate)
self.buttonRelease = self.canvas.mpl_connect('button_release_event', self._endGate)
self.canvas.get_tk_widget().config(cursor='plus')
def _startGate(self, event):
self.start_x = event.xdata
self.start_y = event.ydata
def _endGate(self, event):
#draw gate rectangle
start_x = self.start_x if self.start_x < event.xdata else event.xdata
start_y = self.start_y if self.start_y < event.ydata else event.ydata
width = np.absolute(event.xdata-self.start_x)
height = np.absolute(event.ydata-self.start_y)
rect = Rectangle((start_x, start_y), width, height,
fill=False, ec='black', alpha=1, lw=2)
self.ax.add_patch(rect)
self.canvas.draw()
#disable mouse events
self.canvas.mpl_disconnect(self.buttonPress)
self.canvas.mpl_disconnect(self.buttonRelease)
self.canvas.get_tk_widget().config(cursor='arrow')
#save cell gate
gate = Path([[start_x, start_y],
[start_x + width, start_y],
[start_x + width, start_y + height],
[start_x, start_y + height],
[start_x, start_y]])
gated_cells = self.scdata.tsne.index[gate.contains_points(self.scdata.tsne)]
self.gates[self.gateName.get()] = gated_cells
#replot tSNE w gate colored
self.fig.clf()
plt.scatter(self.scdata.tsne['x'], self.scdata.tsne['y'], s=10, edgecolors='none', color='lightgrey')
plt.scatter(self.scdata.tsne.ix[gated_cells, 'x'], self.scdata.tsne.ix[gated_cells, 'y'], s=10, edgecolors='none')
self.canvas.draw()
self.setGateButton.config(state='disabled')
self.visMenu.entryconfig(6, state='disabled')
def resetCanvas(self):
self.fig.clf()
if type(self.canvas) is FigureCanvasTkAgg:
for item in self.canvas.get_tk_widget().find_all():
self.canvas.get_tk_widget().delete(item)
else:
for item in self.canvas.find_all():
self.canvas.delete(item)
def quitWB(self):
self.quit()
self.destroy()