def load(self):
absfilename=tkFileDialog.askopenfilename(title="Choose an algorithm file",filetypes=[("Algorithm",("*.f90","*.F90")),("All files","*.*")])
# the parser requires us to be in the same directory. This should be fixed.
path,filename=os.path.split(absfilename)
os.chdir(path)
ast,invokeInfo=parse(filename,api="gunghoproto")
self.algtext.delete(1.0, END)
self.psy=PSyFactory("gunghoproto").create(invokeInfo)
# *************************************
# USE invoke object (or some unique text from the invoke) as the tag so each object gets its own callback?
# need to link invoke objects to line numbers (need to be provided by parser)
# hacky temporary alternative just count invokes for the moment
invokeCount=0
for line in str(ast).split("\n"):
if "invoke" in line.lower():
tag="invoke"+str(invokeCount)
self.algtext.insert(tk.INSERT, line+"\n", tag)
bind=Bind(self.algtext,tag,self.psy.invokes.invokeList[invokeCount],self.psytext,self.interact,self.c,self._canvasControl)
self.algtext.tag_bind(tag,"<Enter>", bind.entry)
self.algtext.tag_bind( tag, '<Leave>', bind.leave )
self.algtext.tag_bind( tag, '<ButtonPress-1>', bind.button )
invokeCount+=1
else:
self.algtext.insert(tk.INSERT, line+"\n")
评论列表
文章目录