![]() This function is all the same as the one we used in the command line version of the app the only difference here is that in the try statement, we are getting the day, month, and year from the entries using the get() function and also in the except statement, all errors that the app will catch will be displayed on the showerror popup window. 'Make sure you enter valid data and fill all the fields') # convering year, month and day into birthdateĪge = today.year - birthdate.year - ((today.month, today.day) Invalid input data\n->An empty field/fields\n'\ # we are getting the current date using the today() ![]() Just below the import, paste these lines of code: # defining the for calculating the age, the function takes day ![]() We will now create a function for calculating the age we will call it calculate_age(). Here we are importing date from datetime, this module provides several functions and classes for handling dates and times. Now that the environment is all set, open the age_calculator_cli.py file, and do the following import: from datetime import date Related: How to Make a Calculator with Tkinter in Python. You can call them anything per your preference make sure the file names are meaningful.
0 Comments
Leave a Reply. |