You need to get their values everytime you call the function because they are changing everytime you check or uncheck. Also to update label's text, you need to use something like this. label_name["text"] = "new_text"
Additional to that, Checkbutton
's default on and off values are 1 and 0 respectively. You don't need to write those.
Applying all these to your code, will result this.
from Tkinter import *
def odd_even():
value1 = var1.get()
value2 = var2.get()
value3 = var3.get()
chk_btn_value = value1 + value2 + value3
if chk_btn_value == 0:
changeable_label['text'] = "Null"
elif chk_btn_value % 2 != 0:
changeable_label['text'] = "Odd"
else:
changeable_label['text'] = "Even"
# Create a window
the_window = Tk()
# Give the window a title
the_window.title('Odd or Even')
##Some global variables
margin = 8
text = 'Null'
##Changing the size of the window
the_window.geometry("350x150")
##Making the label frame
labelframe = LabelFrame(the_window, bd = 3)
labelframe.grid(columnspan = 3, padx = margin, pady = margin)
##Adding the Label
changeable_label = Label(labelframe, text = text, font = ('Arial', 60),
fg = ('black'))
changeable_label.pack(side = TOP)
##Addind the Check Buttons
var1 = IntVar()
var2 = IntVar()
var3 = IntVar()
alpha = Checkbutton(the_window, text = 'Alpha', variable = var1,
command = odd_even)
alpha.grid(row = 1, column = 1)
beta = Checkbutton(the_window, text = 'Beta', variable = var2,
command = odd_even)
beta.grid(row = 1, column = 2)
gamma = Checkbutton(the_window, text = 'Gamma', variable = var3,
command = odd_even)
gamma.grid(row = 1, column = 3)
# Start the event loop
the_window.mainloop()