gui.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:PSyclone 作者: stfc 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号