Ejemplo n.º 1
0
 def handle_input(key):
     if key == 'Q' or key == 'q':
         raise urwid.ExitMainLoop()
     elif key == 'R' or key == 'r':
         quote_box.base_widget.set_text(('getting quote',
                                                'Getting new quote...'))
         main_loop.draw_screen()
         quote_box.base_widget.set_text(get_new_joke())
Ejemplo n.º 2
0
def main_loop():
    global stdscr, quote_window, quote_text_window, qw_size

    while True:
        c = quote_window.getch()

        if c == ord('r') or c == ord('R'):
            quote_text_window.clear()
            quote_text_window.addstr("Getting quote...", curses.color_pair(3))
            quote_text_window.refresh()
            quote_text_window.clear()
            quote_text_window.addstr(get_new_joke())

        elif c == ord('q') or c == ord('Q'):
            break

        stdscr.noutrefresh()
        quote_window.noutrefresh()
        quote_text_window.noutrefresh()
        curses.doupdate()