本文整理汇总了Python中WConio.puttext方法的典型用法代码示例。如果您正苦于以下问题:Python WConio.puttext方法的具体用法?Python WConio.puttext怎么用?Python WConio.puttext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WConio
的用法示例。
在下文中一共展示了WConio.puttext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_terminal
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import puttext [as 别名]
def draw_terminal():
y = Terminal.top
W.puttext(Terminal.left, y, Terminal.left + Terminal.width -1, y + Terminal.height -1, Terminal.clear_buffer)
for line in Terminal.buffer[Terminal.scroll_offset:Terminal.scroll_offset+Terminal.height]:
W.puttext(Terminal.left, y, min(Terminal.width, Terminal.left + line.width - 1), y, line.buf)
y += 1
示例2: draw_buffer
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import puttext [as 别名]
def draw_buffer(buf, x, y):
if buf.dirty:
#generate a wconio buffer
buf._text = render_buffer(buf)
buf.dirty = False
W.puttext(x, y,
x + buf.width-1,
y + buf.height-1,
buf._text
)
示例3: draw_condition_bar
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import puttext [as 别名]
def draw_condition_bar(base):
x, y = base.x + len(base.text), base.y
hp, max_hp = game.player.hp, game.player.max_hp
buf = []
for i in range(1, max_hp + 1):
if hp >= i:
color = draw.color_char(W.GREEN)
else:
color = draw.color_char(W.RED)
buf.extend([C.Characters.half_box, color])
buf = "".join(buf)
W.puttext(x, y, x + max_hp - 1, y, buf)
示例4: draw_box
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import puttext [as 别名]
def draw_box(left=None, top=None, width=None, height=None, box=None, **kwargs):
if width is None and box:
#box is a Box namedtuple
width = box.width
height = box.height
if left is None and box:
#and can also have positioning
left = box.left
top = box.top
if box is None and width:
#or you can just give w/h and let it make you one
box = create_box(width, height, left=left, top=top, **kwargs)
W.puttext(left, top, left+width-1, top+height-1, box.buf)
return box
示例5: show_confirmation
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import puttext [as 别名]
def show_confirmation(line1=' ', line2=' '):
line1 = terminal.Line.parse(line1)[0]
line2 = terminal.Line.parse(line2)[0]
width = max(14, max(line1.width, line2.width) + 2)
height = 8
left = (C.width - width) / 2
top = (C.height - height) / 2
previous_buf = W.gettext(left, top, left + width, top + height)
btn_width = 7
btn_height = 4
btn_offset = 3
try:
container = draw.draw_box(left, top, width, height,
border_color=W.LIGHTBLUE, border_background_color = W.BLUE)
W.puttext(left+1, top + 1, left + line1.width, top + 1, line1.buf)
W.puttext(left+1, top + 2, left + line2.width, top + 2, line2.buf)
yes_button = draw.draw_box(left + btn_offset, top + height - btn_height, btn_width, btn_height,
border_color=W.LIGHTBLUE, border_background_color = W.BLUE,
corners = {'bl': 'teeup', 'br': 'teeup'})
no_button = draw.draw_box(left + width - btn_offset - btn_width, top + height - btn_height, btn_width, btn_height,
border_color=W.LIGHTBLUE, border_background_color = W.BLUE,
corners = {'bl': 'teeup', 'br': 'teeup'})
yes_text = draw.Text(W.DARKGREY, 1, 1, "YES".center(btn_width -2 ))
no_text = draw.Text(W.WHITE, 1, 1, "NO".center(btn_width -2 ))
yes_button.text.append(yes_text)
no_button.text.append(no_text)
selected_button = no_button
while True:
if selected_button == yes_button:
yes_text.color = W.WHITE
no_text.color = W.DARKGREY
else:
no_text.color = W.WHITE
yes_text.color = W.DARKGREY
draw.draw_box_text(yes_button)
draw.draw_box_text(no_button)
(chn, chs) = W.getch()
#figure out if we're done
if chs == '\r':
#enter, exit
break
if chs == 'y':
selected_button = yes_button
break
if chs == 'n':
selected_button = no_button
break
if chn == 0 or chn == 224:
#special keys come in two parts
(chn2, _) = W.getch()
if chn2 in W.__keydict:
name = W.__keydict[chn2]
if 'left' in name or 'right' in name:
selected_button = (selected_button == yes_button and no_button or yes_button)
return (selected_button == yes_button and True or False)
finally:
#Restore what we scribbled on
W.puttext(left, top, left + width, top + height, previous_buf)
示例6: draw_scrollbar
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import puttext [as 别名]
def draw_scrollbar():
buf = ''.join(['%s%s' % (a,b) for a,b in Scrollbar.arr])
W.puttext(Scrollbar.left, Scrollbar.top, Scrollbar.left, Scrollbar.top + Terminal.height - 1, buf)
示例7: close
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import puttext [as 别名]
def close(self):
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if self.buffer:
wc.puttext(self.sx, self.sy, self.ex, self.ey, self.buffer)