Question: Python program: A listbox is an excellent widget for selecting from short list of items. Write a program that will allow the user to pick

Python program:

Python program: A listbox is an excellent widget for selecting from short

A listbox is an excellent widget for selecting from short list of items. Write a program that will allow the user to pick a file name from the program's current directory and will display the following in the GUI window: the number of lines in the selected file the average line length of all the lines in the file A TKinter listbox is created using the Listbox() function just like the other widgets we have used. To add items to a listbox, use: .insert(, ) to insert each item. is the position in the list (as an integer), and is what will be inserted. If adding items from a list or tuple, a for loop and enumerate() may be useful! To retrieve the selected item(s) from a listbox, use .curselection() which returns a tuple of all the selected item numbers (the default is to allow only 1 selection, so it will be a tuple with 1 element). To get the actual value(s), you'll need to refer back to the original list or tuple it came from, or use .get(0,tk.END) to get a tuple of all the listbox values. An example might look something like: File Stats Files lecture-110-challenge. lecture-84-challenge.b lecture-91-challenge. sample.txt File length: 22 Average Line length: 41 Get Info

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!