PyQt5 – Setting and accessing name of Radio button
In this article we will see how we can set and access the name of the radio button. Name is basically used to distinguish the radio buttons because when we create GUI (Graphical User Interface) we make lot of radio button and there is a need to distinguish them as some radio button will be for choosing filter some will be for selecting color etc therefore need of naming is required.
In order to access the we use accessibleName method and in order to set the name we use setAccessibleName method.
For setting name –
Syntax : radio_button.setAccessibleName(name)
Argument : It takes string as argument
Return : None
For accessing name –
Syntax : radio_button.accessibleName()
Argument : It takes no argument
Return : It return string
Implementation procedure :
1. Create a radio button
2. Set name to it with the help of setAccessibleName method
3. Create label to display the information
4. Access the name of radio button with the help of accessibleName method and store it in variable
5. Set this name to label with the help of setText method
Below is the implementation –
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course