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

def submitEvent( ):                                             #method is called upon submit
    gender = sexInput.get()                                     #get value selected in Radio group
    messagebox.showinfo('Thanks', F"You entered: {gender}")     #display a popup dialog
    
#### Create the window components ###########################################################

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

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

sexInput  = StringVar()

genderLabel  = Label(frame1, text="Enter your gender", bg="cyan")
maleRadio    = Radiobutton(frame1, text="Male",   variable=sexInput, value="male",   bg='cyan')
femaleRadio  = Radiobutton(frame1, text="Female", variable=sexInput, value="female", bg='cyan')

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

femaleRadio.select()                                                #select a component                            

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

genderLabel.grid( row=0, column=0, pady=6, padx=5, sticky=E)
maleRadio.grid(   row=0, column=1, pady=6, padx=5, sticky=W)
femaleRadio.grid( row=0, column=2, 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