16. Tkinter: Checkboxes

Subscribers:
5,850
Published on ● Video Link: https://www.youtube.com/watch?v=EnmOLGBxvvs



Duration: 6:29
392 views
0


Video code

from tkinter import *

def submit():
if result1.get() == 1:
print("Python is great")
if result2.get() == 1:
print("C++ is great")
if result1.get() == 0 and result2.get() == 0:
print("You do not like either option")


window = Tk()
window.title("My program")
window.geometry("350x200")

result1 = IntVar()
result2 = IntVar()

c1 = Checkbutton(window, text="Python", variable=result1, onvalue=1, offvalue=0)
c1.pack()
c2 = Checkbutton(window, text="C++", variable=result2, onvalue=1, offvalue=0)
c2.pack()

button = Button(window, text="Submit", command=submit)
button.pack(side=BOTTOM, fill =Y,)

window.mainloop()







Tags:
tkinter
python
intro
introduction
tutorial
keyboard
notebook
scroll
text
entry
buttons
radio
combo
checkbox
scales
sliders