In this article we are going to learn how can we create a Radio Box with items in horizontal and vertical direction orientations. In order to do that we are going to use styles parameter while creating Radio Box.
There are two styles in Radio Box.
- wx.RA_SPECIFY_ROWS: The major dimension parameter refers to the maximum number of rows.
- wx.RA_SPECIFY_COLS: The major dimension parameter refers to the maximum number of columns.
Syntax:
wx.RadioBox.RadioBox(parent, id=ID_ANY, label=””, pos=DefaultPosition,
size=DefaultSize, choices=[], majorDimension=0, style=RA_SPECIFY_ROWS,
class=”noIdeBtnDiv”,
validator=DefaultValidator, name=RadioBoxNameStr)
- To set direction vertical we will use wx.RA_SPECIFY_ROWS
- To set number of items per row we will use majorDimension parameter.
- To set direction horizontal we will use wx.RA_SPECIFY_COLS
- To set number of items per colums we will use majorDimension parameter.
Code Example:
import wx class FrameUI(wx.Frame): def __init__(self, parent, title): super(FrameUI, self).__init__(parent, title = title, size =(300, 200)) # function for in-frame components self.InitUI() def InitUI(self): # parent panel for radio box pnl = wx.Panel(self) # list of choices hlist = ['Item One', 'Item Two'] vlist =['Item One', 'Item Two'] # create radio box with items in horizontal orientation self.rbox = wx.RadioBox(pnl, label ='RadioBox', pos =(10, 10), choices = hlist, majorDimension = 0, style = wx.RA_SPECIFY_ROWS) # create radio box with items in vertical orientation self.rbox = wx.RadioBox(pnl, label ='RadioBox', pos =(240, 10), choices = vlist, majorDimension = 0, style = wx.RA_SPECIFY_COLS) # set frame in centre self.Centre() # set size of frame self.SetSize((400, 250)) # show output frame self.Show(True) # wx App instance ex = wx.App() # Example instance FrameUI(None, 'RadioButton and RadioBox') ex.MainLoop() |
Output Window:

Recommended Posts:
- wxPython - Create Radio Box with two step creation
- wxPython - Create Radio Button using Create() function
- wxPython | Get default attributes of Radio Box
- wxPython - Hide Radio Box from the frame
- wxPython - Show hidden Radio Box
- wxPython - Disable Radio Box present in frame
- wxPython - Change font for text present in Radio Box
- wxPython - Create Static Box using Create() method
- PyQt5 - How to hide the items from drop down box in Combo Box
- wxPython - Change Font colour of Radio Button
- wxPython - Change font of Radio Button
- wxPython - Change Background Colour of Radio Button
- wxPython - Set Tooltip for radio button
- wxPython - Disable Radio button
- wxPython - Change Size of Radio Button
- wxPython - Hide Radio Button
- wxPython - Show hidden Radio Button
- wxPython - Get size of Radio Button Window
- PyQt5 - orientation() method Progress Bar
- PyQt5 QDial - Getting Orientation Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

