本文整理汇总了Python中WConio.gettext方法的典型用法代码示例。如果您正苦于以下问题:Python WConio.gettext方法的具体用法?Python WConio.gettext怎么用?Python WConio.gettext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WConio
的用法示例。
在下文中一共展示了WConio.gettext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import gettext [as 别名]
def __init__(self, sx, sy, wd, ht, bgc=None, save=True):
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WindowBase.__init__(self)
self.sx = sx
self.sy = sy
self.ex = sx + wd
self.ey = sy + ht
self.wd = wd
self.ht = ht
self.bgc = bgc
if save:
self.buffer = wc.gettext(self.sx, self.sy, self.ex, self.ey)
else:
self.buffer = None
if self.bgc:
self.clr()
示例2: show_confirmation
# 需要导入模块: import WConio [as 别名]
# 或者: from WConio import gettext [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)