Skip to content
Snippets Groups Projects
Commit 9e74eec8 authored by BIGOT AYMERIC's avatar BIGOT AYMERIC
Browse files

Add new file

parent 2318e5a8
No related merge requests found
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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment