Created
May 22, 2019 08:42
-
-
Save horstjens/7123723dbd70a1ecdd1a8b2c45da7f6c to your computer and use it in GitHub Desktop.
get list out of file ( as choices arguments for easygui.choicebox )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vanilla | |
strawberry | |
apple | |
apricot | |
banana |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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