Apr-07-2019, 12:47 PM
Something like this?
In this example I use just the stdout of the subprogramm, to set the label.
For demonstration, it's called after 5s.
gui.py
In this example I use just the stdout of the subprogramm, to set the label.
For demonstration, it's called after 5s.
gui.py
import sys from tkinter import Tk, Button, Variable from subprocess import check_output from threading import Timer def make_gui(): root = Tk() text = Variable(root) text.set('Before') Button(root, textvariable=text).pack() Button(root, text='Exit', command=root.destroy).pack() return root, text def main(): root, text_var = make_gui() # with threadnig timer #timer = Timer(5, label, args=(text_var,)) #timer.start() # root.after root.after(5000, label, text_var) root.mainloop() def label(text_var): stdout = check_output([sys.executable, 'subprogram.py'], encoding='utf8') text_var.set(stdout) if __name__ == '__main__': sys.exit(main())subprogram.py
#!/usr/bin/env python3 print('Hello Label')
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!