Question 1 Consider Python Gui Program Produces Window Following Widgets Text Box Display Q43906654
QUESTION 1 Consider a Python GUI program that produces a window with the following widgets: • a text box to display the value of one element of a given list(e.g., a list of the five vowels); • a button to retrieve the previous value in that list (if there is one). This button is disabled if there is no previous value in the list. • a button to retrieve the next value in that list (if there is one). This button is disabled if there is no next value in the list. • a label to display the number of the item being displayed and the total number of items (e.g., “1/5”) The initial output is as shown below: 74 Vowels – << prev >> next Hitting the “>>next” button once (from the initial state above) produces the following output: 7 Vowels – << prev Hitting the “>>next” button three more times produces the following output: 76 Vowels – << prev >> next Most of the back-end of the program has already been written. Amongst other things, the following variables have been created: window = Tk () labelCounter = Label(window, text = “”) # to display the current and total item numbers counter = 0 # the index of the list item being displayed input_list = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’] # list of vowels YOUR TASK is to complete the display_counter function which redisplays the item number after a button has been pushed and the counter variable has been updated accordingly (e.g., “2/5”). def display_counter(): output = stri ) + “/” + NB: counter had the value o when the screenshot of the initial output (above) was created. def display_counter(): output = stri counter counter + 1 str(len(input_list) – 1) NB: counter had the value o wl str(lentinput_list) + 1) strlen(input_list)) output = labelCounter[text’] labelCounter[‘text’] = counter/len(input_list) QUESTION 2 labelCounter[text’] – output Show transcribed image text QUESTION 1 Consider a Python GUI program that produces a window with the following widgets: • a text box to display the value of one element of a given list(e.g., a list of the five vowels); • a button to retrieve the previous value in that list (if there is one). This button is disabled if there is no previous value in the list. • a button to retrieve the next value in that list (if there is one). This button is disabled if there is no next value in the list. • a label to display the number of the item being displayed and the total number of items (e.g., “1/5”) The initial output is as shown below: 74 Vowels – next Hitting the “>>next” button once (from the initial state above) produces the following output: 7 Vowels – next” button three more times produces the following output: 76 Vowels – next
Most of the back-end of the program has already been written. Amongst other things, the following variables have been created: window = Tk () labelCounter = Label(window, text = “”) # to display the current and total item numbers counter = 0 # the index of the list item being displayed input_list = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’] # list of vowels YOUR TASK is to complete the display_counter function which redisplays the item number after a button has been pushed and the counter variable has been updated accordingly (e.g., “2/5”). def display_counter(): output = stri ) + “/” + NB: counter had the value o when the screenshot of the initial output (above) was created.
def display_counter(): output = stri counter counter + 1 str(len(input_list) – 1) NB: counter had the value o wl str(lentinput_list) + 1) strlen(input_list)) output = labelCounter[text’] labelCounter[‘text’] = counter/len(input_list) QUESTION 2 labelCounter[text’] – output
Expert Answer
Answer to QUESTION 1 Consider a Python GUI program that produces a window with the following widgets: • a text box to display th…
OR