I have a Gooey based GUI where the user can input a name for the output file to be created at the end of the program. However, I would like to make it only possible to add file names with the .xlsx extension in the end.
This is the validator I have:
parser.add_argument('-Choose_File_Name',
action='store',
help="Output File Name with .xlsx",
gooey_options={
'validator': {
'test': 'str(user_input) == .xlsx',
'message': 'Must contain .xlsx at the end!'
}
})
However it gives me an invalid syntax error for the line 'test': 'str(user_input) == .xlsx'
Use str.endswith
Ex:
parser.add_argument('-Choose_File_Name',
action='store',
help="Output File Name with .xlsx",
gooey_options={
'validator': {
'test': 'user_input.endswith(".xlsx") == True',
'message': 'Must contain .xlsx at the end!'
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.