##########################################################################################
# Create a Tkinter screen with a label, checkboxes and button
##########################################################################################
from tkinter import *			            #import entire tkinter framework
from tkinter import messagebox              #import popup dialogs 

def submitEvent( ):                                         #method is called upon submit
    selected = ""
    if sglInput.get() =='1': selected += sglCheckbox['text'] +' '   #get value selected in Checkbox 
    if mrdInput.get() =='1': selected += mrdCheckbox['text'] +' '   #only display if selected = '1'
    if chldInput.get()=='1': selected += chldCheckbox['text']+' '
    messagebox.showinfo('Thanks', F"You entered: {selected}")       #display a popup dialog
    
#### Create the window components ###########################################################

win = Tk( )					                    #call Tk( ) constructor to create a root window
win.title("Tkinter Window with Check buttons")  #set a window title
win.geometry("400x130")                         #window size

frame1 = Frame( win, bg='cyan', bd=20, highlightthickness=2, highlightbackground="blue")

sglInput  = StringVar()
mrdInput  = StringVar()
chldInput = StringVar()

statusLabel  = Label(frame1, text="Enter marital status", bg="cyan")
sglCheckbox  = Checkbutton(frame1, text="Single",   variable=sglInput,  bg='cyan')
mrdCheckbox  = Checkbutton(frame1, text="Married",  variable=mrdInput,  bg='cyan') 
chldCheckbox = Checkbutton(frame1, text="Children", variable=chldInput, bg='cyan')

submitButton = Button(frame1, width=9, text="Submit", cursor='hand2', command=submitEvent)  #call submitEvent upon submit

sglCheckbox.deselect()                                              #deselect components
mrdCheckbox.deselect()
chldCheckbox.deselect()

#### Place components in window ###########################################################

statusLabel.grid( row=0, column=0, pady=6, padx=5, sticky=E)
sglCheckbox.grid( row=0, column=1, pady=6, padx=5, sticky=W)
mrdCheckbox.grid( row=0, column=2, pady=6, padx=5, sticky=W)
chldCheckbox.grid(row=0, column=3, pady=6, padx=5, sticky=W)
submitButton.grid(row=1, column=0, padx=5, pady=8, sticky=E)

frame1.pack()                                                       #make the frame visible
win.mainloop()                                                      #make the window visible