From: Hiro T. <hi...@as...> - 2008-09-25 12:27:29
|
Hi, I am trying to change my plots using another tk window I made, but it does not work well. I am wondering if someone could help me. Here is an example to try to change the X axis of the plot using scale bars on another Tk window. But once I run the program, the figure window for matplotlib gets darker several second later, and I cannot use pan/zoom buttons etc. -- #!/usr/bin/python from pylab import * from Tkinter import * class TkWindow(Frame): def init(self): self.vmin= IntVar() self.vmax= IntVar() self.vmin.set(0) self.vmax.set(10) l2=Frame(self) scale_vmin=Scale(l2,label='x(min)',variable=self.vmin, to=20,from_=-20,length=200,tickinterval=10, orient=HORIZONTAL) scale_vmax=Scale(l2,label='x(max)',variable=self.vmax, to=20,from_=-20,length=200,tickinterval=10, orient=HORIZONTAL) scale_vmin.pack(side=LEFT,padx=5) scale_vmax.pack(side=LEFT,padx=5) scale_vmin.config(command=self.exec_scales) scale_vmax.config(command=self.exec_scales) l2.pack(fill=X) def exec_scales(self,event): vmin=self.vmin.get() vmax=self.vmax.get() ax.set_xlim(vmin,vmax) draw() def __init__(self,ax,master=None): self.ax=ax Frame.__init__(self,master) self.init() self.pack() ### Begin ### ax=subplot(111) plot(arange(0,10)) tkw=TkWindow(ax) show() tkw.mainloop() --- Thanks a lot for your attention!! Hiro |