|
| 1 | +# Age Calculator GUI |
| 2 | + |
| 3 | +In this age calculator app, users can type in their date of birth, and the app will calculate and display their age. |
| 4 | + |
| 5 | +## Step 1: |
| 6 | + |
| 7 | +First of all, we need to import two libraries into our code. The first one is the *tkinter* library. Then, we need the *datetime* library to work with dates. |
| 8 | + |
| 9 | +## Step 2: |
| 10 | + |
| 11 | +Now, let’s create a simple window for our app and name it as *Age Calculator*. |
| 12 | + |
| 13 | +## Step 3: |
| 14 | + |
| 15 | +Then, we are going to create four labels, each for the name, year, month, and the date, and put them in the grid. |
| 16 | + |
| 17 | +We will create entry fields to get the user inputs corresponding to all the labels created. Put them at the right side of the corresponding labels using the *grid* method. |
| 18 | + |
| 19 | +## Step 4: |
| 20 | + |
| 21 | +Then, we are going to define a function, which will calculate the age of the user by subtracting the user’s birth date from today’s date. We name that function as `ageCalc()`. |
| 22 | + |
| 23 | +Then, we create a `Label` area that will display the age of the user as output in the function itself. |
| 24 | + |
| 25 | +## Step 5: |
| 26 | + |
| 27 | +Then, we are going to create a button for users to submit their input values. We link the button to the `ageCalc` function. |
| 28 | + |
| 29 | +Finally, let’s run everything inside the window using the `mainloop()` method. |
0 commit comments