Skip to content

Instantly share code, notes, and snippets.

@colinjroberts
Last active February 28, 2022 00:40
Show Gist options
  • Save colinjroberts/a6b724f9ec4733287621ccd31c476e90 to your computer and use it in GitHub Desktop.
Save colinjroberts/a6b724f9ec4733287621ccd31c476e90 to your computer and use it in GitHub Desktop.
Part 1 of development of a Python urwid app for tracking information during a job search
import urwid
def exit_program():
"""Exit the main loop and return to the terminal"""
raise urwid.ExitMainLoop()
def q_for_exit(key):
"""Check for key presses for q and quits"""
if key in ('q', 'Q'):
exit_program()
if __name__ == "__main__":
"""Main process that splits the main window into tabs and a main body
using a Pile"""
# Builds primary two subdivisions: tab_menu and body_container
tab_menu = urwid.Text("This is where tabs will go.")
body_container = urwid.Filler(urwid.Text("This is where "
"the body will go."), "top")
# Arrange primary items into a Pile
main_pile = urwid.Pile([('pack', tab_menu), urwid.LineBox(body_container)])
mainloop = urwid.MainLoop(main_pile,
palette=[('reversed', 'standout', '')],
unhandled_input=q_for_exit)
mainloop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment