Beispiel #1
0
def create_plt_fig():
    # print all polls and IDs as guide
    polls = Poll.all()
    print("\n\t\t------Available Polls------\n\n")
    for poll in polls:
        print(f"\t\t{poll.id}: {poll.title} (created by {poll.owner})")

    # select poll of interest
    poll_id = int(input("Enter poll you'd like to see a figure for: "))
    

    # save poll name of selected poll to variable (to pass to create_pie_chart() )
    poll_name = poll_name_by_id(polls, poll_id)

    # get vote info for selected poll
    options, votes = Poll.get_info_for_plt(poll_id) 

    # create figure
    fig = charts.create_pie_chart(options, votes, poll_name)
    plt.show()

    save_plot(options, votes, poll_name)
Beispiel #2
0
def list_open_polls():
    polls = Poll.all()
    print("\n\t\t------Open Polls------\n\n")
    for poll in polls:
        print(f"\t\t{poll.id}: {poll.title} (created by {poll.owner})")