Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial Databases 2nd Symposium Ssd 91 Zurich Switzerland August 1991 Proceedings Lncs 525

Authors: Oliver Gunther ,Hans-Jorg Schek

1st Edition

3540544143, 978-3540544142

More Books

Students also viewed these Databases questions