Skip to content

Instantly share code, notes, and snippets.

@horstjens
Created May 22, 2019 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horstjens/7123723dbd70a1ecdd1a8b2c45da7f6c to your computer and use it in GitHub Desktop.
Save horstjens/7123723dbd70a1ecdd1a8b2c45da7f6c to your computer and use it in GitHub Desktop.
get list out of file ( as choices arguments for easygui.choicebox )
vanilla
strawberry
apple
apricot
banana
# get a list out of a file for use in easygui choices
# exspecting a file called "liste.txt" in the same directory
def get_list_from_file(filename):
clist = []
with open(filename) as f:
for line in f.readlines():
if line != "\n":
clist.append(line.strip())
return clist
print(get_list_from_file("liste.txt"))
# easygui.choicebox("take a choice...", choices=get_list_from_file("liste.txt"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment