Hey everyone. Have you ever wanted to get input but find that raw_input blocks a thread? Even if you was to dual thread, that other thread has to wait for the user to press something befor it closes out fully? Not anymore, I bring you a way to get input and some helpfull commands for panda you can call! Its not 100% but it does work. You can call it in your main thread with out having to dual thread it out… Down side? It only works for windows atm, working on a way for other os to use it but thought someone may want to see how it could be done with in windows.
def DeBug(self):
Read = ""
tempsave = ""
print "Type help(command()) if you need the list of commands."
while self.AllShutDown: #Change this if you put it in your main thread/taskmgr
try:
if os.name in ("nt", "dos", "ce"):
time.sleep(.01)
if msvcrt.kbhit():
line = msvcrt.getch()
if line == '\r':
tempsave = Read
sys.stdout.write('\n')
self.Commands = Read.lower()
if self.Commands == "help()":
print "Commands are -> help(), showcollision(0 or 1), analyze(), pstatclient(), end(), cls(), setfps(60,70), showtask()"
elif self.Commands == "help(command())":
print "Commands are -> help(), showcollision(0 or 1), analyze(), pstatclient()"
print "To find out more about the command, type help(Then your command())."
elif self.Commands == "help(showcollision())":
print "Shows the collision that are made."
print "Added abvs, 0 and 1."
print "0 turns off the render collision and 1 turns it on."
elif self.Commands == "help(analyze())":
print "Prints the current needs of system."
elif self.Commands == "help(pstatclient())":
print "Must have pstatclient running in the background."
print "Shows a more detailed behind the scenes performance metter."
elif self.Commands == "showcollision(1)":
base.cTrav.showCollisions(render)
elif self.Commands == "showcollision(0)":
base.cTrav.hideCollisions()
elif self.Commands == "analyze()":
render.analyze()
elif self.Commands == "pstatclient()":
PStatClient.connect()
elif self.Commands == "end()":
self.AllShutDown = False
sys.exit()
elif self.Commands == "cls()":
os.system('cls')
elif self.Commands == "setfps(60)":
globalClock.setMode(ClockObject.MLimited)
globalClock.setFrameRate(65)
elif self.Commands == "setfps(70)":
globalClock.setMode(ClockObject.MLimited)
globalClock.setFrameRate(75)
elif self.Commands == "showtask()":
taskMgr.popupControls()
else:
print "Command does not excits."
Read = ""
elif line == '\x08':
if Read != "":
x = ""
y = ""
for l in Read:
x = x + '\x08'
y = y + ' '
Read = Read[:-1]
show = x + y + x + Read
sys.stdout.write(show)
elif line == '\x48':
if tempsave != "":
if Read != "":
x = ""
y = ""
for l in Read:
x = x + '\x08'
y = y + ' '
show = x + y + x
sys.stdout.write(show)
Read = tempsave
sys.stdout.write(tempsave)
else:
sys.stdout.write("")
elif line == '\x41' or line == '\x42' or line == '\x43' or line == '\x44' or line == '\x45' or line == '\x46' or line == '\x47' or line == '\x49' or line == '\x4A' or line == '\x4B' or line == '\x4C' or line == '\x4D' or line == '\x4E' or line == '\x4F' or line == '\x50' or line == '\x51' or line == '\x52' or line == '\x53' or line == '\x54' or line == '\x55' or line == '\x56' or line == '\x57' or line == '\x58' or line == '\x59' or line == '\x5A' or line == '\xE0':
pass
else:
Read = Read + line
x = ""
for l in Read:
x = x + '\x08'
show = x + Read
sys.stdout.write(show)
except:
print "Command does not excits."