Dynamic Text output not shown in all terminal environments, but for some it does show the right output no matter what OS system.
I have an issue where I'm running a specific python script which I used dynamic threading to run two functions, but when I run the script, it doesn't run the text dynamically and each time it gives me a different output. I've had other people tried it from both Windows and Mac with PyCharm and works perfectly fine with them. I think it has to do with my environment or the script itself. When I run other scripts, the necessary terminal output works fine. Also, keep in mind that the second line is supposed "Computation in progress" is supposed to be dynamically retyping for 30 secs. I have screenshots of the different terminal outputs and the script code itself if you want to run it and see. Much help is appreciated!
import threading
import time
def progress(stop_event):
# Simulate the progress bar using a while loop
while not stop_event.is_set():
print("\rComputation in progress... /", end="")
def complex_function_1():
print("Function 1 started...")
time.sleep(30)
print("Function 1 completed!")
# Create an Event object to signal the progress to stop
stop_progress_event = threading.Event()
# Create a thread for the progress
progress_thread = threading.Thread(target=progress, args=(stop_progress_event,))
# Start the progress thread
progress_thread.start()
# Call complex_function_1
complex_function_1()
# Signal the progress thread to stop
stop_progress_event.set()
# Wait for the progress thread to finish
progress_thread.join()
请先登录再写评论。
Please try disabling the "Emulate terminal in console output" option and check if the issue persists.