def imageFinder(self):
        root = Tk()
        print('Ran imageFinder')
        latestFile = max(glob.glob('/home/pi/spibox/capture/primout/*'),
                         key=os.path.getctime)

        if latestFile == '/home/pi/spibox/capture/primout/primitive_output100.png':
            self.img2 = PhotoImage(
                file='/home/pi/spibox/capture/primout/primitive_output100.png')
            self.img2Label = Label(image=self.img2,
                                   bg="Black",
                                   width=256,
                                   height=256)
            self.img2Label.grid(row="3")
            root.after(5000, root.quit())
            print('Image updating done')

        else:
            self.img2 = PhotoImage(file=latestFile)
            self.img2Label = Label(image=self.img2,
                                   bg="Black",
                                   width=256,
                                   height=256)
            self.img2Label.grid(row="3")
            root.after(1000, self.imageFinder)
Exemplo n.º 2
0
def raise_app(
    root: tk
):  #this function automatically activates the tkinter frame in MacOS10.10
    root.attributes("-topmost", True)
    if platform.system() == 'Darwin':
        tmpl = 'tell application "System Events" to set frontmost of every process whose unix id is {} to true'
        script = tmpl.format(os.getpid())
        output = subprocess.check_call(['/usr/bin/osascript', '-e', script])
    root.after(0, lambda: root.attributes("-topmost", False))