Page 324 -
P. 324
guis and data
First, you needed to create a function called read_depots() to read the lines in a text file and return them as a list.
1
Start with an
def read_depots(file): empty array.
depots = []
Open the file.
depots_f = open(file)
Read from the file one
line at a time. for line in depots_f:
Append a stripped copy of depots.append(line.rstrip())
the line to the array.
return depots
Return the list to
the calling code.
Then, you needed to replace this section of the code with code that generated an option menu using the data returned
2 by the read_depots() function. It needed to use a file called depots.txt. You were to write the code here:
Call the function, passing in the
name of the file to read the data
from. options = read_depots(“depots.txt")
Use the data to build the OptionMenu(app, depot, *options).pack()
option menu.
you are here 4 289