from tkinter import * master = Tk() var1 = IntVar() Checkbutton(master, text="male", variable=var1).grid(row=0, sticky=W) var2 = IntVar() Checkbutton(master, text="female", variable=var2).grid(row=1, sticky=W) mainloop()
Here is what the above code is Doing:
1. We create a Tk object and assign it to the master variable.
2. We create two IntVar objects and assign them to var1 and var2.
3. We create two checkbuttons, one with the text male and the other with the text female.
4. We use the sticky attribute to make sure the checkbuttons are aligned to the left side of the window.
5. We call the mainloop method to make sure the window is displayed on the screen until we close it.