import tkinter as tk
from tkinter import ttk
from tkinter import messagebox as m_box
win=tk.Tk()

# label frame
label_frame=ttk.LabelFrame(win,text='Contact Details')
label_frame.grid(row=0,column=0,padx=40,pady=20)

# labels
name_label=ttk.Label(label_frame,text='Enter your Name:',font=('Helvetica',14,))
name_label.grid(row=0,column=0,padx=5,pady=5,sticky=tk.W)
age_label=ttk.Label(label_frame,text='Enter your Age:',font=('Helvetica',14,))
age_label.grid(row=0,column=1,padx=5,pady=5,sticky=tk.W)

# entry box
name_var=tk.StringVar()
age_var=tk.StringVar()
name_entry=ttk.Entry(label_frame,width=50,textvariable=name_var)
name_entry.grid(row=1,column=0,padx=5,pady=5,sticky=tk.W)
age_entry=ttk.Entry(label_frame,width=50,textvariable=age_var)
age_entry.grid(row=1,column=1,padx=5,pady=5,sticky=tk.W)

def action():
    # m_box.showwarning('title','content of this message box')
    name=name_var.get()
    age=age_var.get()
    if name==''or age=='':
        m_box.showerror('Error','please fill the entry')
    else:
        try:
            age=int(age)
        except ValueError:
            m_box.showerror('Error','please write your age in digits')
        else:
            print(f'{name}:{age}')            
submit_btn=ttk.Button(win,text='SUBMIT',command=action)
submit_btn.grid(row=1,column=0,padx=40,pady=20)











win.mainloop()