Introduction

In this article, I will explain how to add a Radiobutton in Tkinter in Python.
Definition
The Radiobutton keyword is used as a multiple-choice button, which is a way to offer many possible selections to the user and let the user choose only one of them.
Syntax
  1. w = Radiobutton ( a, option)
Parameters
a − This represents the parent window of the computer.
option − The list of most used options for this widget.
Option & Description
Program
  1. from tkinter import *
  2. a=Tk()
  3. a.geometry("400x400")
  4. a.title("test")
  5. radiobutton1=Radiobutton(a, text="Radiobutton 1",activebackground="black" ,
  6. activeforeground="green",bg="pink",bd=10,cursor = "target").pack()
  7. radiobutton2=Radiobutton(a, text="Radiobutton 2",activebackground="black" ,
  8. activeforeground="green",bg="pink",bd=10,cursor = "target").pack()
  9. radiobutton3=Radiobutton(a, text="Radiobutton 3",activebackground="black" ,
  10. activeforeground="green",bg="pink",bd=10,cursor = "target").pack()
  11. radiobutton4=Radiobutton(a, text="Radiobutton 4",activebackground="black" ,
  12. activeforeground="green",bg="pink",bd=10,cursor = "target").pack()
  13. a.mainloop()
Output
How To Add A RadioButton In Tkinter In Python
Program
  1. from tkinter import *
  2. a=Tk()
  3. a.geometry("400x400")
  4. a.title("test")
  5. radiobutton=Radiobutton(a, text="button 1",fg="blue",
  6. font="Castellar",height=3,width=10,relief="solid").pack()
  7. radiobutton=Radiobutton(a, text="button 2",fg="red",
  8. font="Castellar",height=3,width=10,relief="solid").pack()
  9. radiobutton=Radiobutton(a, text="button 3",fg="blue",
  10. font="Castellar",height=3,width=10,relief="solid").pack()
  11. radiobutton=Radiobutton(a, text="button 4",fg="red",
  12. font="Castellar",height=3,width=10,relief="solid").pack()
  13. a.mainloop()
Output
How To Add A RadioButton In Tkinter In Python
Program
  1. from tkinter import *
  2. a=Tk()
  3. a.geometry("400x400")
  4. a.title("test")
  5. radiobutton=Radiobutton(a, text="button 1",state=DISABLED,
  6. justify=RIGHT,padx=10,pady=10).pack()
  7. radiobutton=Radiobutton(a, text="button 2",state=DISABLED,
  8. justify=RIGHT,padx=10,pady=10).pack()
  9. radiobutton=Radiobutton(a, text="button 3",state=DISABLED,
  10. justify=RIGHT,padx=10,pady=10).pack()
  11. radiobutton=Radiobutton(a, text="button 4",state=DISABLED,
  12. justify=RIGHT,padx=10,pady=10).pack()
  13. a.mainloop()
Output
How To Add A RadioButton In Tkinter In Python

Conclusion

In this article, we have seen how to add a radiobutton in Tkinter in Python. I hope this article was useful to you. Thanks for reading!