Python tkinter Radiobutton solution

import tkinter as tk
my_w=tk.Tk()
my_w.geometry('500x500')
def my_upd():
 if(r1_v.get()==1):
    c1_v.set(1)
    c2_v.set(0)
 elif(r1_v.get()==2):
        c1_v.set(0)
        c2_v.set(1)
    
r1_v=tk.IntVar() # Decleared Integer variable

r1=tk.Radiobutton(my_w,text='PHP',variable=r1_v,value=1,command=my_upd)
r1.grid(row=1,column=1)

r2=tk.Radiobutton(my_w,text='Python',variable=r1_v,value=2,command=my_upd)
r2.grid(row=1,column=2)

c1_v=tk.IntVar() # Decleared Integer variable
c1=tk.Checkbutton(my_w,text='PHP',variable=c1_v,onvalue=1,offvalue=0)
c1.grid(row=2,column=1)

c2_v=tk.IntVar()
c2=tk.Checkbutton(my_w,text='Python',variable=c2_v,onvalue=1,offvalue=0)
c2.grid(row=2,column=2)

my_w.mainloop()
Radio button Tutorial & Exercise


Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer