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


Python FigureCanvasTkAgg.create_oval方法代码示例

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


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

示例1: first_output_window

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import create_oval [as 别名]
class first_output_window(Tkinter.Tk):

    def __init__(self,parent):
        Tkinter.Tk.__init__(self,parent)
        self.parent = parent

        self.protocol("WM_DELETE_WINDOW", self.dest)
        self.main()

    def main(self):
        # prepare figure, frame, canvas
        self.fig = plt.figure(figsize=(4,4))
        self.frame = Tkinter.Frame(self)
        self.frame.grid(padx=10,pady=10)
        self.canvas = FigureCanvasTkAgg(self.fig, master=self.frame)
        self.canvas.get_tk_widget().grid(column=0,row=0)
        # define 3D interactive plot
        self.ax = Axes3D(self.fig)
        # display 3D model on chimera's main window
        opened = chimera.openModels.open('class2_run10k_ct24_it031_class001.mrc')
        tt=chimera.runCommand('volume #0 level 0.02 color pink')
        # button widget to show the chosen angle
        self.btn = Tkinter.Button(self,text=u'Chosen angle',command=self.disp2D)        
        self.btn.grid(column=0,row=2,sticky='EW')
        cid = self.fig.canvas.mpl_connect('button_press_event', self.onclick)
        # button widget for computing chronos and topos
        self.btn = Tkinter.Button(self,text=u'Calculate Topos and Chronos now',command=self.disp2D)        
        self.btn.grid(column=0,row=3,sticky='EW')
        cid = self.fig.canvas.mpl_connect('button_press_event', self.onclick)
        # generate some fake data points
        ss = 100
        tt = 50
        phi = np.ones((ss,1))
        theta = np.ones((ss,1))
        for i in range(phi.shape[0]):
            phi[i] = random.uniform(0,2*np.pi)
            theta[i] = random.uniform(0,np.pi)
        phi1 = np.array([[0],[np.pi/2],[np.pi/20]])
        theta1 = np.array([[0],[np.pi/2],[np.pi/20]])
        phi1 = npm.repmat(phi1,tt,1)
        theta1 = npm.repmat(theta1,tt,1)
        self.p = geo.euler_to_vect(theta, phi)
        self.p1 = geo.euler_to_vect(theta1, phi1)
        self.points=[]
        # display data points on the unit sphere
        self.ax.view_init(elev=0, azim=90)
        t = self.ax.scatter(self.p[:,0], self.p[:,1], self.p[:,2],  marker='o', s=10, c="goldenrod", alpha=0.6)
        t = self.ax.scatter(self.p1[:,0],self.p1[:,1],self.p1[:,2], marker='+', s=10, c="red", alpha=0.6)
        # display data points that are in the front view
        self.disp2D()
        #
        self.canvas2 = Tkinter.Canvas(self.frame,bg="white", width=4,height=4)
        self.canvas2.configure(cursor="crosshair")
        self.canvas2.grid(column=0,row=1)
        self.canvas2.bind('<Button-1>', self.point)
        # gui grid adjustments
        #self.grid_columnconfigure(0,weight=0)
        #self.resizable(False,False)
        
    # method to update the display of points in the front view
    def disp2D(self):
        # print 1
        self.fig1 = Figure(figsize=(4,4))    
        self.ax1 = self.fig1.add_subplot(111)
        pt = geo.proj_sphere(self.ax.elev,self.ax.azim,self.p)
        pt1 = geo.proj_sphere(self.ax.elev,self.ax.azim,self.p1)
        #print self.ax.azim, self.ax.elev
        # aa = pt[:,0]
        #print aa.ndim
        #print aa.shape
        self.ax1.scatter(pt[:,0],pt[:,1],marker = 'o',c="goldenrod")
        self.ax1.scatter(pt1[:,0],pt1[:,1],marker = '+',c="red")
        self.canvas1 = FigureCanvasTkAgg(self.fig1, master=self.frame)
        self.canvas1.get_tk_widget().grid(column=0,row=1)
        #self.canvas2 = Tkinter.Canvas(self.frame,width=4,height=4)
        #self.canvas2.configure(cursor="crosshair")
        #self.canvas2.grid(column=0,row=1)
        #self.canvas2.bind("<Button-1>", self.point)
        cid1 = self.canvas1.mpl_connect('button_press_event', self.onclick1)
        chimera.runCommand('turn x %f'%self.ax.azim)
        print 'elev = %f, azim=%f,'%(self.ax.elev,self.ax.azim)
        return
        
    def dest(self):
        self.destroy()
        sys.exit()

    def scroll(self):
        self.canvas2=Tkinter.Canvas(self.frame)
        self.frame1=Tkinter.Frame(self.canvas2)
        self.vbar=Tkinter.Scrollbar(self.frame,orient="vertical",command=self.canvas2.yview)
        self.canvas2.configure(yscrollcommand=self.vbar.set)
        self.vbar.pack(side="right",fill="y")
        self.canvas2.pack(side='left')
        self.canvas2.create_window((0,0),window=self.frame1,anchor='nw')
        
    def point(self, event):
        self.canvas1.create_oval(event.x, event.y, event.x+1, event.y+1, fill="black")
        self.points.append(event.x)
        self.points.append(event.y)
#.........这里部分代码省略.........
开发者ID:hstau,项目名称:manifold-cryo,代码行数:103,代码来源:gui.py


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