本文整理汇总了Python中x84.bbs.getch函数的典型用法代码示例。如果您正苦于以下问题:Python getch函数的具体用法?Python getch怎么用?Python getch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getch函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: pak
def pak():
""" Press any key prompt. """
from x84.bbs import echo, getch
msg_pak = u'PRESS ANY kEY'
echo(u'\r\n%s ... ' % (msg_pak,))
getch()
return
开发者ID:quastdog,项目名称:x84,代码行数:7,代码来源:lc.py
示例2: refresh
def refresh():
""" Refresh screen and return top-left (x, y) location. """
# set syncterm font to cp437
if term.kind.startswith('ansi'):
echo(syncterm_setfont('cp437'))
echo(u'\r\n\r\n')
if term.width < width:
echo(u''.join((
term.move(term.height, 0),
u'\r\n\r\n',
term.bold_red + 'screen too thin! (%s/%s)' % (
term.width, width,),
u'\r\n\r\n',
u'press any key...',)))
getch()
return (None, None)
if term.height < height:
echo(u''.join((
term.move(term.height, 0),
u'\r\n\r\n',
term.bold_red + 'screen too short! (%s/%s)' % (
term.height, height),
u'\r\n\r\n',
u'press any key...',)))
getch()
return (None, None)
xloc = (term.width / 2) - (width / 2)
yloc = (term.height / 2) - (height / 2)
echo(u''.join((
term.normal,
(u'\r\n' + term.clear_eol) * term.height,
u''.join([term.move(yloc + abs_y, xloc) + line
for abs_y, line in enumerate(otxt)]),)))
return xloc, yloc
开发者ID:tehmaze,项目名称:x84,代码行数:34,代码来源:si.py
示例3: do_search
def do_search(search):
"""
Given any arbitrary string, return list of possible matching locations.
"""
import StringIO
from x84.bbs import echo, getch
disp_msg(u'SEARChiNG')
resp = requests.get(u'http://apple.accuweather.com'
+ u'/adcbin/apple/Apple_find_city.asp',
params=(('location', search),))
locations = list()
if resp is None:
disp_notfound()
elif resp.status_code != 200:
# todo: logger.error
echo(u'\r\n' + u'Status Code: %s\r\n\r\n' % (resp.status_code,))
echo(repr(resp.content))
echo(u'\r\n\r\n' + 'Press any key')
getch()
else:
# print resp.content
xml_stream = StringIO.StringIO(resp.content)
locations = list([dict(elem.attrib.items())
for _event, elem in ET.iterparse(xml_stream)
if elem.tag == 'location'])
if 0 == len(locations):
disp_notfound()
else:
disp_found(len(locations))
return locations
开发者ID:tehmaze,项目名称:x84,代码行数:30,代码来源:weather.py
示例4: view_ansi
def view_ansi(key):
""" fetch and view a bbs ansi. They're not often very good ...
"""
from x84.bbs import getterminal, echo, DBProxy, ini, getch, from_cp437
term = getterminal()
ansiurl = DBProxy('bbslist')[key]['ansi']
logger = logging.getLogger()
echo(u'\r\n\r\n')
if ansiurl is not None and 0 != len(ansiurl) and ansiurl != 'NONE':
usernm = ini.CFG.get('bbs-scene', 'user')
passwd = ini.CFG.get('bbs-scene', 'pass')
req = requests.get(ansiurl, auth=(usernm, passwd))
if req.status_code != 200:
echo(u'\r\n\r\nrequest failed,\r\n')
echo(u'%r' % (req.content,))
echo(u'\r\n\r\n(code : %s).\r\n' % (req.status_code,))
echo(u'\r\nPress any key ..')
logger.warn('ansiurl request failed: %s' % (ansiurl,))
getch()
return
ansi_txt = from_cp437(sauce.SAUCE(data=req.content).__str__())
echo(ansi_txt)
else:
echo('no ansi available (%s)' % (ansiurl,))
# move to bottom of screen and getch
echo(u''.join((
term.move(term.height, 0),
term.normal,
u'\r\n\r\nPRESS ANY kEY ...'),))
getch()
开发者ID:jonny290,项目名称:yos-x84,代码行数:30,代码来源:bbslist.py
示例5: do_fetch
def do_fetch(postal):
"""
Given postal code, fetch and return xml root node of weather results.
"""
from x84.bbs import echo, getch, getterminal
import StringIO
term = getterminal()
disp_msg('fEtChiNG')
resp = requests.get(u'http://apple.accuweather.com'
+ u'/adcbin/apple/Apple_Weather_Data.asp',
params=(('zipcode', postal),))
if resp is None:
disp_notfound()
return None
if resp.status_code != 200:
# todo: logger.error
echo(u'\r\n')
echo(term.bold_red(u'StAtUS COdE: %s' % (resp.status_code,)))
echo(u'\r\n\r\n')
echo(repr(resp.content))
echo(u'\r\n\r\n' + 'PRESS ANY kEY')
getch()
return None
xml_stream = StringIO.StringIO(resp.content)
tree = ET.parse(xml_stream)
return tree.getroot()
开发者ID:quastdog,项目名称:x84,代码行数:26,代码来源:weather.py
示例6: dummy_pager
def dummy_pager(user):
""" A dummy selector for profile attributes """
from x84.bbs import getsession, getterminal, echo, Ansi, getch
session, term = getsession(), getterminal()
plan = user.get('.plan', False)
from x84.bbs.ini import CFG
def_timeout = CFG.getint('system', 'timeout')
menu = ['(c)%-20s - %s' % (u'hARACtER ENCOdiNG',
term.bold(session.encoding),),
'(t)%-20s - %s' % (u'ERMiNAl tYPE',
term.bold(session.env.get('TERM', 'unknown')),),
'(h)%-20s - %s' % (u'ERMiNAl hEiGht',
term.bold(str(term.height)),),
'(w)%-20s - %s' % (u'ERMiNAl WidtH',
term.bold(str(term.width)),),
'(l)%-20s - %s' % (u'OCAtiON',
term.bold(user.location),),
'(p)%-20s - %s' % (u'ASSWORd',
term.bold_black(u'******'),),
'(!)%-20s - %s' % (u'Set SA User Cookie',
term.bold(user['sausercookie']),),
'(@)%-20s - %s' % (u'Set SA Pass Cookie',
term.bold_black(user['sapasscookie']),),
'(e)%-20s - %s' % (u'-MAil AddRESS',
term.bold(user.email),),
# '(!)%-20s - %s' % (u'SA User Cookie',
# term.bold(user['sausercookie']),),
# '(@)%-70s - %s' % (u'SA Pass Cookie',
# term.bold(user['sapasscookie']),),
(term.bold('t') +
'(i)%-19s - %s' % (u'MEOUt', term.bold(
str(user.get('timeout', def_timeout))),)),
'(s)%-20s - %s' % (u'YSOP ACCESS',
term.bold(u'ENAblEd'
if 'sysop' in user.groups
else 'diSAblEd')),
'(m)%-20s - %s' % (u'ESG',
term.bold(u'[%s]' % ('y'
if user.get(
'mesg', True) else 'n',),)),
'(.)%-20s - %s' % (u'PlAN filE', '%d bytes' % (
len(plan),) if plan else '(NO PlAN.)'),
'(x)%-20s - %s' % (u'PERt MOdE',
term.bold(u'ENAblEd'
if user.get('expert', False)
else 'diSAblEd')),
'(q)Uit', ]
echo(term.normal + term.clear() )
lines = Ansi('\n'.join(menu)).wrap(term.width).splitlines()
xpos = max(1, int(term.width / 2) - (40 / 2))
for row, line in enumerate(lines):
if row and (0 == row % (term.height - 2)):
echo(term.reverse(u'\r\n-- More --'))
getch()
echo(u'\r\n' + ' ' * xpos + line)
echo(u'\r\n\r\n Enter option [ctle.xq]: ')
return process_keystroke(getch(), user)
开发者ID:jonny290,项目名称:yos-x84,代码行数:57,代码来源:profile.py
示例7: disp_notfound
def disp_notfound():
""" Display 'bad request -/- not found in red. """
from x84.bbs import getsession, getterminal, echo, getch
term = getterminal()
echo(u''.join((u'\r\n\r\n',
term.bold(u'bAd REQUESt'),
term.bold_red(' -/- '),
term.bold('NOt fOUNd.',),)))
if not getsession().user.get('expert', False):
getch(1.7)
开发者ID:quastdog,项目名称:x84,代码行数:10,代码来源:weather.py
示例8: waitprompt
def waitprompt():
# Displays a simple "press enter to continue prompt". Very handy!
from x84.bbs import echo, getch, getterminal
term = getterminal()
echo (term.normal+'\n\r'+term.magenta+'('+term.green+'..'+term.white+
' press any key to continue '+term.green+'..'+term.magenta+')')
getch()
echo(term.normal_cursor)
return
开发者ID:hick,项目名称:x84,代码行数:10,代码来源:common.py
示例9: disp_notfound
def disp_notfound():
""" Display 'bad request -/- not found in red. """
from x84.bbs import getsession, getterminal, echo, getch
term = getterminal()
bad_req = term.bold(u'bAd REQUESt')
decorator = term.bold_red(u'-/-')
not_found = term.bold('NOt fOUNd.')
echo('\r\n\r\n{bad_req} {decorator} {not_found}'.format(
bad_req=bad_req, decorator=decorator, not_found=not_found))
if not getsession().user.get('expert', False):
getch(1.7)
开发者ID:jonny290,项目名称:yos-x84,代码行数:11,代码来源:weather.py
示例10: main
def main():
""" Main routine. """
from x84.bbs import getsession, getterminal, echo, getch
session, term = getsession(), getterminal()
session.activity = 'Weather'
echo(u'\r\n\r\n')
location = session.user.get('location', dict())
while True:
search = location.get('postal', u'')
disp_search_help()
search = get_zipsearch(search)
if search is None or 0 == len(search):
return # exit
locations = do_search(search)
if 0 != len(locations):
location = (locations.pop() if 1 == len(locations)
else chose_location(locations) or dict())
root = do_fetch(location.get('postal'))
if root is None:
return
weather = parse_weather(root)
#if False == location_prompt(location, 'WEAthER'):
# break
disp_weather(weather)
if False == location_prompt(location, 'fORECASt'):
break
forecast = parse_forecast(root)
disp_forecast(forecast)
echo(u'\r\n')
echo(term.yellow_reverse('--ENd Of tRANSMiSSiON--'))
getch()
break
if (sorted(location.items())
!= sorted(session.user.get('location', dict()).items())):
echo(u''.join((u'\r\n\r\n',
term.yellow(u'SAVE lOCAtION'),
term.bold_yellow(' ('),
term.bold_black(u'PRiVAtE'),
term.bold_yellow(') '),
term.yellow('? '),
term.bold_yellow(u'['),
term.underline_yellow(u'yn'),
term.bold_yellow(u']'),
u': '),))
while True:
inp = getch()
if inp is None or inp in (u'n', u'N', 'q', 'Q', term.KEY_EXIT):
break
if inp in (u'y', u'Y', u' ', term.KEY_ENTER):
session.user['location'] = location
break
开发者ID:quastdog,项目名称:x84,代码行数:53,代码来源:weather.py
示例11: main
def main(ttyfile=u'', peek=False):
""" Main procedure. """
from x84.bbs import Lightbar, getch, getsession, getterminal, ini, echo
# pylint: disable=R0914,R0915
# Too many local variables
# Too many statements
ttyplay_exe = ini.CFG.get('ttyplay', 'exe')
if not os.path.exists(ttyplay_exe):
echo(u'\r\n%s NOt iNStAllEd.\r\n' % (ttyplay_exe,))
getch()
return
session, term = getsession(), getterminal()
# pylint: disable=W0212
# Access to a protected member _record_tty of a client class
resume_rec = session._record_tty and session.is_recording
if resume_rec:
session.stop_recording()
session._record_tty = False
if 'sysop' in session.user.groups and ttyfile == u'':
# pylint: disable=W0212
# Access to a protected member _ttyrec_folder of a client class
folder = os.path.dirname(ttyfile) or session._ttyrec_folder
pos = None
while True:
files = sorted([fn for fn in os.listdir(session._ttyrec_folder)
if fn.endswith('.ttyrec')])
echo(u'\r\n' * term.height)
sel = Lightbar(term.height - 1, term.width - 1, 0, 0)
sel.colors['border'] = term.bold_green
echo(sel.border() + sel.title('- SElECt A RECORdiNG -'))
sel.update([(fname, fname) for fname in files])
if pos is not None:
sel.position = pos
x_ttyfile = sel.read()
if x_ttyfile is None or sel.quit:
break
pos = sel.position
ttyfile = os.path.join(folder, x_ttyfile)
playfile(ttyplay_exe, ttyfile, peek)
else:
playfile(ttyplay_exe, ttyfile, peek)
if not session.is_recording and resume_rec:
session._record_tty = True
session.start_recording()
echo(term.move(term.height, 0))
echo(u'\r\n')
开发者ID:donfanning,项目名称:x84,代码行数:50,代码来源:ttyplay.py
示例12: disp_forecast
def disp_forecast(forecast):
""" Display weather forecast. """
from x84.bbs import getterminal, echo, Ansi, getch
term = getterminal()
lno = 1
echo(u'\r\n')
for key in sorted(forecast.keys()):
fcast = forecast[key]
rstr = u''.join((
term.bold_yellow_underline(fcast['DayCode']),
u', ',
u'/'.join(fcast['ObsDate'].split('/', 3)[0:2]),
term.bold_underline(u':'), u' ',
u'%s. ' % (
term.bold(
fcast.get('TXT_Long', fcast.get('TXT_Short', u''))),),
u'hiGH Of %sF, lOW Of %sF. ' % (
term.bold(fcast.get('High_Temperature')),
term.bold(fcast.get('Low_Temperature')),),))
if 0.0 != float(fcast.get('Snow_Amount', '0.0')):
rstr += u'SNOW AMOUNt %s iN., ' % (
term.yellow(fcast.get('Snow_Amount')),)
if 0.0 != float(fcast.get('Rain_Amount', '0.0')):
rstr += u'RAiN AMOUNt %s iN., ' % (
term.yellow(fcast.get('Snow_Amount')),)
if 0.0 != float(fcast.get('Precip_Amount', '0.0')):
rstr += u'PRECiPiTAtiON %s iN., ' % (
term.yellow(fcast.get('Precip_Amount')),)
if 0 != int(fcast.get('TStorm_Prob', '0')):
rstr += u'thUNdERStORM PRObAbilitY: %s, ' % (
term.yellow(fcast.get('TStorm_Prob')),)
if 0 != len(fcast.get('WindDirection', u'')):
rstr += u'WiNdS %s ' % (
term.yellow(fcast.get('WindDirection')),)
if 0 != len(fcast.get('WindSpeed', u'')):
rstr += u'At %sMPh, ' % (
term.yellow(fcast.get('WindSpeed')),)
if 0 != len(fcast.get('WindGust', u'')):
rstr += u'GUStS Of %sMPh. ' % (
term.yellow(fcast.get('WindGust')),)
if 0 != len(fcast.get('Real_Feel_High', u'')):
rstr += u'PROdUCiNG '
if 0 != len(fcast.get('Real_Feel_High', u'')):
rstr += u'A WiNdCHill HiGh Of %sF, lOW %sF. ' % (
term.yellow(
fcast.get('Real_Feel_High')),
term.yellow(
fcast.get('Real_Feel_Low', u'?')),)
echo(u'\r\n')
lno += 1
lines = Ansi(rstr).wrap(min(60, int(term.width * .8))).splitlines()
for line in lines:
lno += 1
echo(line + u'\r\n')
if 0 == lno % (term.height - 1):
echo(term.yellow_reverse('--MORE--'))
if getch() is None:
return False
echo(u'\r\n')
开发者ID:quastdog,项目名称:x84,代码行数:60,代码来源:weather.py
示例13: yes_no
def yes_no(lightbar, msg, prompt_msg='are you sure? ', attr=None):
""" Prompt user for yes/no, returns True for yes, False for no. """
term = getterminal()
keyset = {
'yes': (u'y', u'Y'),
'no': (u'n', u'N'),
}
echo(u''.join((
lightbar.border(),
lightbar.pos(lightbar.yloc + lightbar.height - 1, lightbar.xpadding),
msg, u' ', prompt_msg,)))
sel = Selector(yloc=lightbar.yloc + lightbar.height - 1,
xloc=term.width - 25, width=18,
left='Yes', right=' No ')
sel.colors['selected'] = term.reverse_red if attr is None else attr
sel.keyset['left'].extend(keyset['yes'])
sel.keyset['right'].extend(keyset['no'])
echo(sel.refresh())
while True:
inp = getch()
echo(sel.process_keystroke(inp))
if((sel.selected and sel.selection == sel.left)
or inp in keyset['yes']):
# selected 'yes',
return True
elif((sel.selected or sel.quit)
or inp in keyset['no']):
# selected 'no'
return False
开发者ID:tehmaze,项目名称:x84,代码行数:29,代码来源:editor.py
示例14: displayfile
def displayfile(filename):
term = getterminal()
echo(term.clear + term.move(0, 0) + term.normal)
text = {}
counter = 0
offset = 0
keypressed = ''
# the string array named text will be zerobased
for line in showart(filename):
text[counter] = line
counter = counter + 1
while True:
echo(term.move(0, 0) + term.normal)
# -2 om man vill spara en rad i botten
for i in range(0, term.height - 1):
if len(text) > i + offset:
echo(term.clear_eol + u'\r' + text[i + offset])
keypressed = getch()
echo(term.hide_cursor)
if keypressed == 'q' or keypressed == 'Q' or keypressed == term.KEY_ESCAPE or keypressed == term.KEY_ENTER:
break
if keypressed == term.KEY_HOME:
offset = 0
if keypressed == term.KEY_END:
# if the textline has fewer lines than the screen..
if len(text) < term.height:
offset = 0
else:
offset = len(text) - term.height + 1
if keypressed == term.KEY_DOWN:
# offset < len(text) + term.height:
if len(text) > offset + term.height - 1:
offset = offset + 1
if keypressed == term.KEY_UP:
if offset > 0:
offset = offset - 1
if keypressed == term.KEY_LEFT or keypressed == term.KEY_PGUP:
if offset > term.height:
offset = offset - term.height + 2
else:
offset = 0
if keypressed == term.KEY_RIGHT or keypressed == term.KEY_PGDOWN:
if (offset + term.height * 2) - 1 < len(text):
offset = offset + term.height - 2
else:
# if the textline has fewer lines than the screen..
if len(text) < term.height:
offset = 0
else:
offset = len(text) - term.height + 1
开发者ID:rostob,项目名称:x84,代码行数:60,代码来源:textbrowse.py
示例15: chk_save_location
def chk_save_location(location):
"""
Prompt user to save location for quick re-use
"""
from x84.bbs import getterminal, getsession, echo, getch
session, term = getsession(), getterminal()
stored_location = session.user.get('location', dict()).items()
if (sorted(location.items()) == sorted(stored_location)):
# location already saved
return
if session.user.handle == 'anonymous':
# anonymous cannot save preferences
return
# prompt to store (unsaved/changed) location
echo(u'\r\n\r\n')
echo(term.yellow(u'Save Location'))
echo(term.bold_yellow(u' ('))
echo(term.bold_black(u'private'))
echo(term.bold_yellow(u') '))
echo(term.yellow(u'? '))
echo(term.bold_yellow(u'['))
echo(term.underline_yellow(u'yn'))
echo(term.bold_yellow(u']'))
echo(u': ')
while True:
inp = getch()
if inp is None or inp in (u'n', u'N', u'q', u'Q', term.KEY_EXIT):
break
if inp in (u'y', u'Y', u' ', term.KEY_ENTER):
session.user['location'] = location
break
开发者ID:tehmaze,项目名称:x84,代码行数:32,代码来源:weather.py
示例16: prompt_ok
def prompt_ok():
"""
Prompt user to continue, True if they select yes.
"""
from x84.bbs import getsession, getterminal, echo, getch, Selector
session, term = getsession(), getterminal()
prompt_confirm = u'EVERYthiNG lOOk Ok ?'
prompt_continue = u'YES (CONtiNUE)'
prompt_chg = u'NO! (ChANGE)'
def prompt_ok_dumb():
""" Dummy terminal prompt for confirm/cancel. """
echo('\r\n\r\n%s\r\n' % (prompt_confirm,))
echo('1 - %s\r\n' % (prompt_continue,))
echo('2 - %s\r\n\r\n' % (prompt_chg,))
echo('select (1, 2) --> ')
while True:
inp = getch()
if inp == u'1':
return True
elif inp == u'2':
return False
if session.env.get('TERM') == 'unknown':
return prompt_ok_dumb()
sel = Selector(yloc=term.height - 1, xloc=5,
width=term.width - 10,
left=prompt_continue, right=prompt_chg)
echo(term.normal)
echo(term.move(term.height - 2, 0) + term.clear_eol)
echo(prompt_confirm.center(term.width - 1) + '\r\n')
echo(term.clear_eol + sel.refresh())
while True:
echo(sel.process_keystroke(getch()))
if sel.selected:
return True if sel.selection == prompt_continue else False
开发者ID:jonny290,项目名称:yos-x84,代码行数:35,代码来源:nua.py
示例17: get_centigrade
def get_centigrade():
"""
Blocking prompt for setting C/F preference
"""
from x84.bbs import getterminal, getsession, echo, getch
term = getterminal()
session = getsession()
echo(u'\r\n\r\n')
echo(term.yellow(u'Celcius'))
echo(term.bold_yellow(u'('))
echo(term.bold_yellow_reverse(u'C'))
echo(term.bold_yellow(u')'))
echo(u' or ')
echo(term.yellow(u'Fahrenheit'))
echo(term.bold_yellow(u'('))
echo(term.bold_yellow_reverse(u'F'))
echo(term.bold_yellow(u')'))
echo(u'? ')
anonymous = bool(session.user.handle == 'anonymous')
while True:
inp = getch()
if inp in (u'c', u'C'):
session.user['centigrade'] = True
if not anonymous:
session.user.save()
break
elif inp in (u'f', u'F'):
session.user['centigrade'] = False
if not anonymous:
session.user.save()
break
elif inp in (u'q', u'Q', term.KEY_EXIT):
break
开发者ID:hick,项目名称:x84,代码行数:33,代码来源:weather.py
示例18: chk_save_location
def chk_save_location(location):
"""
Prompt user to save location for quick re-use
"""
from x84.bbs import getterminal, getsession, echo, getch
session, term = getsession(), getterminal()
stored_location = session.user.get('location', dict()).items()
if (sorted(location.items()) == sorted(stored_location)):
return
# prompt to store (unsaved/changed) location
echo(u'\r\n\r\n')
echo(term.yellow(u'SAVE lOCAtION'))
echo(term.bold_yellow(' ('))
echo(term.bold_black(u'PRiVAtE'))
echo(term.bold_yellow(') '))
echo(term.yellow('? '))
echo(term.bold_yellow(u'['))
echo(term.underline_yellow(u'yn'))
echo(term.bold_yellow(u']'))
echo(u': ')
while True:
inp = getch()
if inp is None or inp in (u'n', u'N', u'q', u'Q', term.KEY_EXIT):
break
if inp in (u'y', u'Y', u' ', term.KEY_ENTER):
session.user['location'] = location
break
开发者ID:jonny290,项目名称:yos-x84,代码行数:28,代码来源:weather.py
示例19: add_comment
def add_comment(key):
""" Prompt user to add a comment about a bbs. """
# pylint: disable=R0914
# Too many local variables.
from x84.bbs import getsession, getterminal, echo, DBProxy, LineEditor
from x84.bbs import getch
session, term = getsession(), getterminal()
prompt_comment = u'\r\n\r\nWhAt YOU GOt tO SAY? '
prompt_chg = u'\r\n\r\nChANGE EXiStiNG ? [yn] '
echo(term.move(term.height, 0))
echo(prompt_comment)
comment = LineEditor(max(10, term.width - len(prompt_comment) - 5)).read()
if comment is None or 0 == len(comment.strip()):
return
new_entry = (session.handle, comment)
comments = DBProxy('bbslist', 'comments')
comments.acquire()
existing = comments[key]
if session.handle in (_nick for (_nick, _cmt) in comments[key]):
# change existing comment,
echo(prompt_chg)
if getch() not in (u'y', u'Y'):
comments.release()
return
# re-define list without existing entry, + new entry
comments[key] = [(_enick, _ecmt) for (_enick, _ecmt) in existing
if session.handle != _enick] + [new_entry]
comments.release()
return
# re-define as existing list + new entry
comments[key] = existing + [new_entry]
comments.release()
开发者ID:jonny290,项目名称:yos-x84,代码行数:32,代码来源:bbslist.py
示例20: get_centigrade
def get_centigrade():
"""
Blocking prompt for setting C/F preference
"""
from x84.bbs import getterminal, getsession, echo, getch
term = getterminal()
session = getsession()
echo(u'\r\n\r\n')
echo(term.yellow(u'CElCiUS'))
echo(term.bold_yellow(u'('))
echo(term.bold_yellow_reverse(u'C'))
echo(term.bold_yellow(u')'))
echo(u' or ')
echo(term.yellow(u'fAhRENhEit'))
echo(term.bold_yellow(u'('))
echo(term.bold_yellow_reverse(u'F'))
echo(term.bold_yellow(u')'))
echo('? ')
while True:
inp = getch()
if inp in (u'c', u'C'):
session.user['centigrade'] = True
session.user.save()
break
elif inp in (u'f', u'F'):
session.user['centigrade'] = False
session.user.save()
break
elif inp in (u'q', u'Q', term.KEY_EXIT):
break
开发者ID:jonny290,项目名称:yos-x84,代码行数:30,代码来源:weather.py
注:本文中的x84.bbs.getch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论