Skip to content

Instantly share code, notes, and snippets.

@dheaney
Last active December 30, 2015 21:19
Show Gist options
  • Select an option

  • Save dheaney/7886386 to your computer and use it in GitHub Desktop.

Select an option

Save dheaney/7886386 to your computer and use it in GitHub Desktop.
import urwid
def show_or_exit(key):
if key in ('q', 'Q'):
raise urwid.ExitMainLoop()
txt.set_text(repr(key))
banner = u"""
____ __ __ __
/ __ \__ __/ /_/ /_ ________ ____ _/ /__
/ / / / / / / __/ __ \/ ___/ _ \/ __ `/ //_/
/ /_/ / /_/ / /_/ /_/ / / / __/ /_/ / ,<
\____/\__,_/\__/_.___/_/ \___/\__,_/_/|_|
==========================================="""
description = u"Press any key to continue"
copyright = u"Copyright 2013 David Heaney"
banner = urwid.Text(('banner', banner), 'center')
description = urwid.Text(('description', description), 'center')
copyright = urwid.Text(('copyright', copyright), 'center')
blank = urwid.Text("")
pile = urwid.Pile([banner, copyright, blank, blank, blank, blank, description])
top = urwid.Filler(pile)
try:
urwid.MainLoop(top, unhandled_input=show_or_exit).run()
except:
os.system('cls' if os.name=='nt' else 'clear')
while True:
print "hello"
for (i, t) in enumerate(("one", "two", "three")):
print i + 1, t
choice = int(raw_input("Choose one: "))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment