I'm creating a small little terminal program. I would like to display the changing time, among other things. To display the time, I use the datetime module, along with the blessed module. My code looks like this:
import blessed
from datetime import datetime
def displayTime():
location = term.get_location()
while True:
currentTime = datetime.now()
a = datetime(currentTime.year, currentTime.month, currentTime.day, currentTime.hour, currentTime.minute, currentTime.second)
with term.location():
print(term.move_xy(location[1], location[0]) + str(a))
time.sleep(1)
This works perfectly fine. Now, I need to print other things to the output window. Or execute a function.
I tried this by using threading.
import threading
time = threading.Thread(target = displayTime())
time.start()
print("test")
However, this failed to do it's job. This should have resulted with output that printed this:
2023-08-23 hour:minute:second test
But I did not get the expected result. If you have an answer, I would also like to know if user input is possible as well. Thank you.