本文整理汇总了Python中WConio.wherex方法的典型用法代码示例。如果您正苦于以下问题:Python WConio.wherex方法的具体用法?Python WConio.wherex怎么用?Python WConio.wherex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WConio
的用法示例。
在下文中一共展示了WConio.wherex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: writeout
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import wherex [as 别名]
def writeout(s, o, c=True, replace_lines=0):
'''Writes out a string to the stdout or appends it to a file'''
if not o:
if c:
s = deutfize(s)
if replace_lines and sys.platform in WINDOWS:
try:
import WConio
pos = WConio.wherex(), WConio.wherey()
for i in range(replace_lines):
sys.stdout.write(' '*(WConio.gettextinfo()[-3]-1) + '\n')
WConio.gotoxy(pos[0], pos[1])
except:
replace_lines=0
sys.stdout.write(s)
if replace_lines and sys.platform in WINDOWS:
WConio.gotoxy(pos[0], pos[1])
else:
with open(o, mode='a', encoding='utf-8') as o_file:
o_file.write(s)
示例2: run
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import wherex [as 别名]
def run ( self ):
time.sleep(3)
oldLen = 0
while 1:
newLen = len(l)
WConio.textcolor(WConio.LIGHTCYAN)
posX = WConio.wherex()
posY = WConio.wherey()
WConio.gotoxy(0,4)
if newLen < oldLen:
for n in range(oldLen+1):
WConio.cputs(" \n\r")
else:
for n in range(len(l)+1):
WConio.cputs(" \n\r")
WConio.gotoxy(0,4)
for i in range(len(l)):
try:
print str(i) + ': ' + str(l[i][2])
except:
print str(i) + ': ' + str(l[i][1][0])
if posX > 16:
WConio.gotoxy(posX,22)
else:
WConio.gotoxy(17,22)
oldLen = len(l)
time.sleep(3)
示例3: run
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import wherex [as 别名]
def run ( self ):
WConio.textcolor(WConio.LIGHTGREEN)
IPs = []
time.sleep(1)
while 1:
r = open('C:\\PyBot\\connections.txt', 'r')
str = r.read().split("\n")
r.close()
for i in str:
if i != '':
try:
IPs.index(i)
except:
IPs.append(i)
f = open('C:\\PyBot\\update.txt', 'w')
x = WConio.wherex()
y = WConio.wherey()
for st in IPs:
f.write(st + '\n')
WConio.gotoxy(0,4)
WConio.cputs(st + '\n\r')
f.close()
WConio.gotoxy(x, y)
time.sleep(2)
示例4: get_input
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import wherex [as 别名]
def get_input():
buf = []
while True:
msg = ''.join(buf)
matches = display_suggestion(msg)
W.gotoxy(0, C.height - 1)
W.clreol()
W.textcolor(W.GREEN)
W.cputs(game.state.current_node.command_prompt + '$ '),
W.textcolor(W.LIGHTGREEN)
W.cputs(msg)
if matches and len(matches) == 1:
#show the argument help text
match = matches[0]
x = W.wherex()
W.textcolor(W.DARKGREY)
splitted = match.arguments.split()
splitted = splitted[max(0, len(msg.split())-2):]
W.cputs(' ' + ' '.join(splitted))
W.textcolor(W.LIGHTGREEN)
W.gotoxy(x, C.height - 1)
else:
match = None
#Read input
W.setcursortype(1)
(chn, chs) = W.getch()
W.setcursortype(0)
#figure out if we're done
if chs == '\r':
#enter, exit
break
if chn == 8:
#backspace
if len(buf):
buf.pop()
else:
MessageBeep()
continue
if chn == 3:
log.debug('took a ctrl-c')
game.fire('specialkey', 'ctrlc')
break
if chn == 0 or chn == 224:
#special keys come in two parts
(chn2, _) = W.getch()
if chn2 in W.__keydict:
game.fire('specialkey', W.__keydict[chn2])
continue
if len(buf) >= C.width:
#way too long now
break
if chs not in string.printable:
#dont care
continue
buf.append(chs)
return buf, match