如何在窗口关闭之前保持python脚本的执行?

时间:2018-08-16 13:44:04

标签: python

这是我的脚本:

import pyke
import matplotlib.pyplot as plt
from shutil import copyfile

class star:

    def __init__(self, path, name,definedaper=False):
        self.path=path
        self.name=name

        self.infile=path+name
        self.maskout = self.infile+'_maskout'

    def aperdef(self):
            plt.interactive(True)

            %matplotlib
            pyke.kepmask(self.infile)
            # WAIT HERE UNTIL MATPLOTLIB WINDOW CLOSED
            copyfile('maskfile.txt',self.maskout)


    def loadaper(self):
        with open('maskfile.txt') as f:
            maskfile = f.read()
        f.closed
        cords=maskfile.split("|")[5]
        cordlist=cords.split(";")

        cordlistmat=[]
        for index, line in enumerate(cordlist):
            cordlistmat.append(line.split(","))


def main():
    ourstar = star('/home/pal/konkoly/go10037/','ktwo201085427-c101_lpd-targ.fits')
    ourstar.aperdef() 

    ourstar.loadaper()


if __name__ == "__main__":
    main()

pyke.kepmask(self.infile)将打开一个窗口,用户可以与之交互,并通过该窗口创建文件maskfile.txt。我希望脚本不使用 copyfile('maskfile.txt',self.maskout)直到窗口关闭。 我该如何实现?比不断检查maskfile.txt是否存在更好的方法,然后再等待是否不存在?

我用于输入的文件ourstar = star('/home/pal/konkoly/go10037/','ktwo201085427-c101_lpd-targ.fits')在此处可用: https://github.com/zabop/starclass_pub/blob/master/ktwo201085427-c101_lpd-targ.fits

0 个答案:

没有答案