diff --git a/projet_texte/interface b/projet_texte/interface new file mode 100644 index 0000000000000000000000000000000000000000..c8a818c2e72b86d6f5448b74b99135f30dcdd436 --- /dev/null +++ b/projet_texte/interface @@ -0,0 +1,41 @@ +import tkinter as tk +import os +import sys +import subprocess + + +# --- functions --- + +def test(): + print("Hello World") + p = subprocess.run("ls", shell=True, stdout=subprocess.PIPE) + print(p.stdout.decode()) + + +# --- classes --- + +class Redirect(): + + def __init__(self, widget): + self.widget = widget + + def write(self, text): + self.widget.insert('end', text) + + +# --- main --- + +root = tk.Tk() + +text = tk.Text(root) +text.pack() + +button = tk.Button(root, text='TEST', command=test) +button.pack() + +old_stdout = sys.stdout +sys.stdout = Redirect(text) + +root.mainloop() + +sys.stdout = old_stdout