-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Expand file tree
/
Copy pathAge_Calculator.py
More file actions
67 lines (46 loc) · 1.87 KB
/
Age_Calculator.py
File metadata and controls
67 lines (46 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from _datetime import datetime
import tkinter as tk
from tkinter import ttk
from _datetime import *
win = tk.Tk()
win.title("Age Calculate")
win.geometry("310x400")
# win.iconbitmap('pic.png') this is use extention ico then show pic
############################################ Frame ############################################
pic = tk.PhotoImage(file=r"E:\Python Practice\Age_calculate\pic.png")
win.tk.call("wm", "iconphoto", win._w, pic)
canvas = tk.Canvas(win, width=310, height=190)
canvas.grid()
image = tk.PhotoImage(file=r"E:\Python Practice\Age_calculate\pic.png")
canvas.create_image(0, 0, anchor="nw", image=image)
frame = ttk.Frame(win)
frame.place(x=40, y=220)
############################################ Label on Frame ############################################
name = ttk.Label(frame, text="Name : ", font=("", 12, "bold"))
name.grid(row=0, column=0, sticky=tk.W)
year = ttk.Label(frame, text="Year : ", font=("", 12, "bold"))
year.grid(row=1, column=0, sticky=tk.W)
month = ttk.Label(frame, text="Month : ", font=("", 12, "bold"))
month.grid(row=2, column=0, sticky=tk.W)
date = ttk.Label(frame, text="Date : ", font=("", 12, "bold"))
date.grid(row=3, column=0, sticky=tk.W)
############################################ Entry Box ############################################
name_entry = ttk.Entry(frame, width=25)
name_entry.grid(row=0, column=1)
name_entry.focus()
year_entry = ttk.Entry(frame, width=25)
year_entry.grid(row=1, column=1, pady=5)
month_entry = ttk.Entry(frame, width=25)
month_entry.grid(row=2, column=1)
date_entry = ttk.Entry(frame, width=25)
date_entry.grid(row=3, column=1, pady=5)
def age_cal():
name_entry.get()
year_entry.get()
month_entry.get()
date_entry.get()
cal = datetime.today() - (int(year_entry))
print(cal)
btn = ttk.Button(frame, text="Age calculate", command=age_cal)
btn.grid(row=4, column=1)
win.mainloop()