Pyro.699
October 5th, 2010, 04:06 AM
Hey all,
I found something that might help a few people out. A quick and easy way to remove all of the text on your terminal. For sure all i know is that it works with python on Linux although im sure it will work in other languages.
All you need to do is print this text \x1b[H\x1b[2J, ill also paste the source for a quick 'timer' program that i was using this for:
#!/usr/bin/python
import threading, datetime, time, sys, random
class Timer(threading.Thread):
def __init__(self, itemName, doneTime):
threading.Thread.__init__(self)
self.name = itemName
self.time = doneTime
self.str = ""
self.daemon = True
def run(self):
while True:
now = datetime.datetime.now()
self.str = "%s: %s"%(self.name, self.time-now)
time.sleep(0.1)
taskList = []
taskList.append( Timer(" Portal 2 ", datetime.datetime(2011, 2, 9, 00, 00, 00, 00)) )
taskList.append( Timer("Call of Duty: Black Ops", datetime.datetime(2010, 11, 9, 00, 00, 00, 00)) )
for task in taskList:
task.start()
while True:
sys.stdout.write( '\x1b[H\x1b[2J' )
out = ""
for task in taskList:
out += "%s\n"%task.str
sys.stdout.write( out )
time.sleep(0.2)
Enjoy
~Cody
I found something that might help a few people out. A quick and easy way to remove all of the text on your terminal. For sure all i know is that it works with python on Linux although im sure it will work in other languages.
All you need to do is print this text \x1b[H\x1b[2J, ill also paste the source for a quick 'timer' program that i was using this for:
#!/usr/bin/python
import threading, datetime, time, sys, random
class Timer(threading.Thread):
def __init__(self, itemName, doneTime):
threading.Thread.__init__(self)
self.name = itemName
self.time = doneTime
self.str = ""
self.daemon = True
def run(self):
while True:
now = datetime.datetime.now()
self.str = "%s: %s"%(self.name, self.time-now)
time.sleep(0.1)
taskList = []
taskList.append( Timer(" Portal 2 ", datetime.datetime(2011, 2, 9, 00, 00, 00, 00)) )
taskList.append( Timer("Call of Duty: Black Ops", datetime.datetime(2010, 11, 9, 00, 00, 00, 00)) )
for task in taskList:
task.start()
while True:
sys.stdout.write( '\x1b[H\x1b[2J' )
out = ""
for task in taskList:
out += "%s\n"%task.str
sys.stdout.write( out )
time.sleep(0.2)
Enjoy
~Cody