python - tuplex out of range when working with buttons -


i have program works fine when try buttons,when run it,it gives me

file "/usr/lib/python2.7/lib-tk/tkinter.py", line 1413, in call

return self.func(*args)   file "fire_buttons.py", line 193, in plot  result=la.graph(grids)   file "fire_buttons.py", line 181, in graph  n=sc.shape(data)[2] indexerror: tuple index out of range 

the function that:

 def graph(self,data):             """make plot"""             plt.colormaps()             n=sc.shape(data)[2]             ims=[]             in range(n):                 mydata=data[:,:,i]                 im=plt.imshow(mydata,cmap=plt.get_cmap('jet'))                 ims.append([im])             return ims 

some code buttons:

def createwidgets(self):         """add widgets main frame"""         top_frame=frame(self)         self.tree=stringvar()         self.tree_entry=entry(top_frame,textvariable=self.tree)         self.label1=label(top_frame,text="probability of existence of tree")         self.tree_entry.pack(side='right')         self.label1.pack()         top_frame.pack(side=top)    ......         bottom_frame=frame(self)         bottom_frame.pack(side=top)         self.quit=button(bottom_frame,text='quit',command=self.quit)         self.quit.pack(side=left)         self.operate=button(bottom_frame,text='run',command=self.plot)         self.operate.pack(side=left)  def plot(self):         if (self.area.get().isdigit() , p.match(self.tree.get())  , p.match(self.burning.get())  , p.match(self.lighting.get()) , p.match(self.resistburn.get()) , p.match(self.regeneratetree.get()) , self.time_step.get().isdigit()):                la=myfire()             grids=la.fire(int(self.area.get()),float(self.tree.get()),float(self.burning.get()),float(self.lighting.get()),float(self.resistburn.get()),float(self.regeneratetree.get()),int(self.time_step.get()))             result=la.graph(grids)             fig=plt.gcf()             artistanimation(fig,result,interval=10,repeat=false)             plt.show() 

also,if want use slide widget tried sth like:

self.tree_entry=scale(top_frame,from_=0,to=1,orient=horizontal,length=1000, tickinterval=0.001) self.tree_entry.set(40) 

i want values 0 1 , increment 0.0001.but gives me 0 , 1 only.

--------------------update--------------------

in version without buttons instead of plot function use:

grids=fire(area,tree,burning,lighting,resistburn,regeneratetree,time_step) result=graph(grids) fig=plt.gcf() ani=artistanimation(fig,result,interval=10,repeat=false) plt.show() 

and runs fine,so maybe have sth wrong in plot?

your error on line:

n=sc.shape(data)[2] 

from evidence you've given, has nothing buttons or widgets in way. you're trying element 2 tuple tuple doesn't have many elements. need find define sc.shape(data) , see why doesn't have many items think should.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -