Python GUI RadioButton in wxPython

In this Python GUI article i want to show you Creating RadioButton in wxPython.

so in wxPython RadioButton item is a button which usually denotes one of several mutually exclusive options. It has a text label next to a (usually) round button.so you can create a group of mutually-exclusive radio buttons. by specifying RB_GROUP for the first in the group.

 

 

 

 

Also you can check More GUI Development Tutorials in the below link.

1: PyQt5 GUI Development Tutorials

2: TKinter GUI Development Tutorials

3: Pyside2 GUI Development Tutorials 

4: Kivy GUI Development Tutorials

 

 

 

 

This class supports the following styles:

  • wx.RB_GROUP: Marks the beginning of a new group of radio buttons.
  • wx.RB_SINGLE: In some circumstances, radio buttons that are not consecutive siblings trigger a hang bug in Windows (only). If this happens, add this style to mark the button as not belonging to a group, and implement the mutually-exclusive group behaviour yourself.

 

 

 

 

So this is the complete code for Python GUI Creating RadioButton in wxPython

 

 

 

 

This is class is MyFrame class that inherits from wx.Frame and it is a top level window that contains our panel.

 

 

 

 

After that we have MyPanel class that inherits from wx.Panel and it is the place that we create our widgets and layouts in this class. you can see that we have created our three RadioButton in this class .

 

 

 

 

So in our MyPanel class these codes are for creating RadioButton in wxPython.

 

 

 

This is our StaticText that we will use this when we do binding for our RadioButton

 

 

 

And this is the binding process. you can see that we have bonded the RadioButton with our onRadioButton method

 

 

 

This is the event method for our RadioButton

 

 

 

 

So the last class is MyApp class that inherits from wx.App. the OnInit() method is where you will most often create frame subclass objects. and start our main loop.That’s it. Once the application’s main event loop processing takes over, control passes to wxPython. Unlike procedural programs, a wxPython GUI program primarily responds to the events taking place around it, mostly determined by a human user clicking with a mouse and typing at the keyboard. When all the frames in an application have been closed, the app.MainLoop() method will return and the program will exit.

 

 

 

 

 

Run the code this will be the result

Python GUI RadioButton in wxPython
Python GUI RadioButton in wxPython

 

 

 

 

 

Also you can watch the complete video for this article

Subscribe and Get Free Video Courses & Articles in your Email

 

Codeloop
Share via
Copy link
Powered by Social Snap
×