Exemplo n.º 1
0
def main():
    """
    The main method of the nuncium application will initialize the execution of
    the program. Threads will be used to query for user input. Each window has
    its own thread to manage the update of its own interface.
    """

    # UI object: The user interface of the nuncium application.
    ui = UI()

    # Integer: The height will consist of the entire screen and the width will
    #          consist of approximately 1/5 of the screen's width.
    height = curses.LINES
    width = int(curses.COLS / 5)

    # String: The default news category that is displayed on startup.
    category = "Top Stories"

    # Window object: The window that will render the menu interface.
    menu_window = ui.window(height, width)
    ui.display_menu(menu_window, category, color=curses.COLOR_BLUE)

    # Integer: The starting position in the x-coordinate of the news window will
    #          be rendered where the last window left off. The width of the news
    #          window will consist of the remaining free space.
    x = width
    width = curses.COLS - width

    # Window object: The window that will render the news content.
    news_window = ui.window(height, width, x, y=0)

    # News object: The news aggregator of the nunicum application.
    news = News()
    news.fetch_news(ui, news_window)

    ui.cursor(menu_window, x=1, y=1, y2=1, current="Top Stories")

    # Thread object: A thread used for updating the menu and news content.
    menu_thread = Thread(target=update, args=(menu_window,), daemon=True)
    news_thread = Thread(target=update, args=(news_window,), daemon=True)

    menu_thread.start()
    news_thread.start()

    # Wait for the threads to finish working.
    while running:
        pass

    ui.cleanup()